Skip to content

Commit 13b77cd

Browse files
sshaderConvex, Inc.
authored andcommitted
Prevent double cleanup on repeted SIGINT (#29127)
It seems like under certain circumstances, one of which is running `npx convex dev` in our monorepo, we receive `SIGINT` twice. Instead of digging into exactly why this happens twice, I'm making it so we only run the `cleanupHandle` once by setting it to `null` immediately before running. GitOrigin-RevId: d88cf278c0c1ba6530a58b358d6a7465cfae2ebb
1 parent 24a936d commit 13b77cd

File tree

1 file changed

+7
-2
lines changed
  • npm-packages/convex/src/cli

1 file changed

+7
-2
lines changed

npm-packages/convex/src/cli/dev.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,15 @@ export const dev = new Command("dev")
174174
...cmdOptions,
175175
localOptions,
176176
});
177+
let cleanupHandle = credentials.cleanupHandle;
177178
process.on("SIGINT", async () => {
178179
logVerbose(ctx, "Received SIGINT, cleaning up...");
179-
if (credentials.cleanupHandle !== null) {
180-
await credentials.cleanupHandle?.();
180+
if (cleanupHandle !== null) {
181+
logVerbose(ctx, "About to run cleanup handle.");
182+
// Sometimes `SIGINT` gets sent twice, so set `cleanupHandle` to null to prevent double-cleanup
183+
const f = cleanupHandle;
184+
cleanupHandle = null;
185+
await f();
181186
}
182187
logVerbose(ctx, "Cleaned up. Exiting.");
183188
process.exit(-2);

0 commit comments

Comments
 (0)