Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/commands/local/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,15 @@ async function* runWithVerify(
);
}

const onSigint = () => child.kill("SIGINT");
const onSigterm = () => child.kill("SIGTERM");
let signalReceived: NodeJS.Signals | null = null;
const onSigint = () => {
signalReceived = "SIGINT";
child.kill("SIGINT");
};
const onSigterm = () => {
signalReceived = "SIGTERM";
child.kill("SIGTERM");
};
process.once("SIGINT", onSigint);
process.once("SIGTERM", onSigterm);

Expand Down Expand Up @@ -465,6 +472,13 @@ async function* runWithVerify(
await shutdownServer(server);
}

// Re-emit the signal after cleanup so the default handler terminates the
// process instead of continuing with the outcome switch below.
if (signalReceived) {
process.kill(process.pid, signalReceived);
return;
}

switch (outcome.kind) {
case "envelope": {
logger.info("Setup verified — your app is sending events to Sentry");
Expand Down
21 changes: 19 additions & 2 deletions src/lib/init/verify-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,15 +282,24 @@ export async function verifySetup(
return;
}

// Track whether the user sent an interrupt so we can re-emit it after
// cleanup instead of silently continuing the wizard.
let signalReceived: NodeJS.Signals | null = null;
const safeKill = (sig: NodeJS.Signals) => {
try {
child.kill(sig);
} catch {
logger.debug(`Child already exited when forwarding ${sig}`);
}
};
const onSigint = () => safeKill("SIGINT");
const onSigterm = () => safeKill("SIGTERM");
const onSigint = () => {
signalReceived = "SIGINT";
safeKill("SIGINT");
};
const onSigterm = () => {
signalReceived = "SIGTERM";
safeKill("SIGTERM");
};
process.once("SIGINT", onSigint);
process.once("SIGTERM", onSigterm);

Expand Down Expand Up @@ -333,6 +342,14 @@ export async function verifySetup(
process.removeListener("SIGTERM", onSigterm);
await shutdownServer(server);

// Re-emit the signal after cleanup so the default handler terminates the
// process. Without this, Ctrl+C during verification would be swallowed and
// the wizard would continue as if nothing happened.
if (signalReceived) {
process.kill(process.pid, signalReceived);
return;
}

// If the child crashed (non-zero exit) but the startup watcher resolved
// first as "started" or "silent", correct to "exited" so the crash is
// reported instead of a false success or misleading timeout message.
Expand Down
Loading