We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c9589f2 commit 8eb5dd4Copy full SHA for 8eb5dd4
1 file changed
bin/scope.js
@@ -99,15 +99,24 @@ export async function scope(filePath) {
99
})
100
101
// Handle graceful shutdown
102
- process.on('SIGINT', () => {
103
- console.log('\nShutting down hyperscope connection...')
104
- ws.close()
105
- })
106
-
107
- process.on('SIGTERM', () => {
+ let shuttingDown = false
+ function shutdown() {
+ if (shuttingDown) {
+ // Second signal: force exit
+ ws.terminate()
+ process.exit(1)
108
+ }
109
+ shuttingDown = true
110
console.log('\nShutting down hyperscope connection...')
111
ws.close()
112
+ // Fallback in case the close handshake hangs
113
+ setTimeout(() => {
114
115
+ process.exit(0)
116
+ }, 2000).unref()
117
118
+ process.on('SIGINT', shutdown)
119
+ process.on('SIGTERM', shutdown)
120
}
121
122
/**
0 commit comments