Skip to content

Commit e50caae

Browse files
fix: await gracefulKill in timeout callback, trim script value before split
- Make setTimeout callback async so gracefulKill's promise is awaited - Trim script value before whitespace split to avoid empty argv[0]
1 parent 744915e commit e50caae

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/commands/local/run.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,9 @@ export const runCommand = buildCommand({
256256

257257
let timeoutId: ReturnType<typeof setTimeout> | undefined;
258258
if (flags.timeout > 0) {
259-
timeoutId = setTimeout(() => {
259+
timeoutId = setTimeout(async () => {
260260
logger.warn(`Timeout: killing child after ${flags.timeout}s`);
261-
gracefulKill(child);
261+
await gracefulKill(child);
262262
}, flags.timeout * 1000);
263263
}
264264

src/lib/dev-script.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ async function tryPackageJson(cwd: string): Promise<DetectedCommand | null> {
7474
// Scripts with env-var prefixes, pipes, or operators need a shell
7575
const args = SHELL_FEATURES_RE.test(value)
7676
? ["sh", "-c", value]
77-
: value.split(WHITESPACE_RE);
77+
: value.trim().split(WHITESPACE_RE);
7878
return {
7979
args,
8080
source: `package.json scripts.${name}`,

0 commit comments

Comments
 (0)