Skip to content

Commit 5de3f14

Browse files
committed
Force SIGINT fallback during CLI exit
1 parent a22d8cf commit 5de3f14

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

cli/src/hooks/use-exit-handler.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ export const useExitHandler = ({
6969
}
7070

7171
scheduleGracefulExit()
72+
// Belt-and-suspenders: if graceful exit stalls, force a SIGINT/exit shortly after.
73+
setTimeout(() => {
74+
try {
75+
process.kill(process.pid, 'SIGINT')
76+
} catch {
77+
// ignore
78+
}
79+
}, 80)
80+
setTimeout(() => {
81+
try {
82+
process.exit(0)
83+
} catch {
84+
// ignore
85+
}
86+
}, 400)
7287
}, [])
7388

7489
const flushAnalyticsWithTimeout = useCallback(async (timeoutMs = 1000) => {

0 commit comments

Comments
 (0)