Skip to content

Commit 8eb5dd4

Browse files
committed
Force terminate hyperscope
1 parent c9589f2 commit 8eb5dd4

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

bin/scope.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,24 @@ export async function scope(filePath) {
9999
})
100100

101101
// Handle graceful shutdown
102-
process.on('SIGINT', () => {
103-
console.log('\nShutting down hyperscope connection...')
104-
ws.close()
105-
})
106-
107-
process.on('SIGTERM', () => {
102+
let shuttingDown = false
103+
function shutdown() {
104+
if (shuttingDown) {
105+
// Second signal: force exit
106+
ws.terminate()
107+
process.exit(1)
108+
}
109+
shuttingDown = true
108110
console.log('\nShutting down hyperscope connection...')
109111
ws.close()
110-
})
112+
// Fallback in case the close handshake hangs
113+
setTimeout(() => {
114+
ws.terminate()
115+
process.exit(0)
116+
}, 2000).unref()
117+
}
118+
process.on('SIGINT', shutdown)
119+
process.on('SIGTERM', shutdown)
111120
}
112121

113122
/**

0 commit comments

Comments
 (0)