Skip to content

Commit c171241

Browse files
fix: default 30s timeout for --verify, redact env vars from telemetry
- Always add a timeout racer in runWithVerify — defaults to 30s when no explicit --timeout is given, preventing indefinite hangs - Redact KEY=VALUE env-var assignments in the detectedCommand telemetry field to avoid leaking secrets from package.json scripts
1 parent 06bdcd5 commit c171241

2 files changed

Lines changed: 19 additions & 22 deletions

File tree

src/commands/local/run.ts

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,9 @@ export const runCommand = buildCommand({
278278
},
279279
});
280280

281+
/** Default timeout for --verify when no explicit --timeout is given. */
282+
const DEFAULT_VERIFY_TIMEOUT_S = 30;
283+
281284
/**
282285
* Run in --verify mode: start a background server, subscribe to the buffer
283286
* for the first envelope, and race between envelope arrival, timeout,
@@ -337,29 +340,21 @@ async function* runWithVerify(
337340
code,
338341
}));
339342

343+
const verifyTimeout =
344+
flags.timeout > 0 ? flags.timeout : DEFAULT_VERIFY_TIMEOUT_S;
345+
340346
let timeoutHandle: ReturnType<typeof setTimeout> | undefined;
341347

342-
const racers: Promise<
343-
| { kind: "envelope" }
344-
| { kind: "exited"; code: number }
345-
| { kind: "timeout" }
346-
>[] = [
348+
const outcome = await Promise.race([
347349
envelopeReceived.then(() => ({ kind: "envelope" as const })),
348350
childExited,
349-
];
350-
351-
if (flags.timeout > 0) {
352-
racers.push(
353-
new Promise((r) => {
354-
timeoutHandle = setTimeout(
355-
() => r({ kind: "timeout" as const }),
356-
flags.timeout * 1000
357-
);
358-
})
359-
);
360-
}
361-
362-
const outcome = await Promise.race(racers);
351+
new Promise<{ kind: "timeout" }>((r) => {
352+
timeoutHandle = setTimeout(
353+
() => r({ kind: "timeout" as const }),
354+
verifyTimeout * 1000
355+
);
356+
}),
357+
]);
363358

364359
if (timeoutHandle !== undefined) {
365360
clearTimeout(timeoutHandle);
@@ -375,13 +370,13 @@ async function* runWithVerify(
375370
}
376371
case "timeout": {
377372
logger.warn(
378-
`Verification timed out after ${flags.timeout}s — no events received from the SDK`
373+
`Verification timed out after ${verifyTimeout}s — no events received from the SDK`
379374
);
380375
child.kill("SIGTERM");
381376
await child.exited;
382377
await shutdownServer(server);
383378
throw new CliError(
384-
`Verification timed out after ${flags.timeout}s`,
379+
`Verification timed out after ${verifyTimeout}s`,
385380
EXIT.WIZARD_VERIFY
386381
);
387382
}

src/lib/init/verify-setup.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ export async function verifySetup(
139139
};
140140
const telemetryExtra = {
141141
features: result.result?.features,
142-
detectedCommand: detected.args.join(" "),
142+
detectedCommand: detected.args
143+
.join(" ")
144+
.replace(/[A-Z_]+=\S+/g, (m) => `${m.split("=")[0]}=[REDACTED]`),
143145
detectedSource: detected.source,
144146
};
145147

0 commit comments

Comments
 (0)