Skip to content

Commit 58ad76f

Browse files
sshaderConvex, Inc.
authored andcommitted
Be defensive against flushAndExit getting called twice (#30992)
There's some evidence that this can get triggered twice (like multiple SIGINTs firing under certain configurations). To ensure the cleanup functions only run once, I'm grabbing them + clearing them before we run them and hit the await points. GitOrigin-RevId: b3b7953455dc32c2131133013d8d84ce5df4a013
1 parent ba9a916 commit 58ad76f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/bundler/context.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,11 @@ class OneoffContextImpl {
8484
};
8585
flushAndExit = async (exitCode: number, err?: any) => {
8686
logVerbose(this, "Flushing and exiting");
87-
const fns = Object.values(this._cleanupFns);
87+
const cleanupFns = this._cleanupFns;
88+
// Clear the cleanup functions so that there's no risk of running them twice
89+
// if this somehow gets triggered twice.
90+
this._cleanupFns = {};
91+
const fns = Object.values(cleanupFns);
8892
logVerbose(this, `Running ${fns.length} cleanup functions`);
8993
for (const fn of fns) {
9094
await fn();

0 commit comments

Comments
 (0)