@luutuankiet/gsd-reader 0.2.18 → 0.2.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.cjs +19 -1
- package/package.json +1 -1
package/cli.cjs
CHANGED
|
@@ -260,7 +260,18 @@ function httpRequest(url, options, data) {
|
|
|
260
260
|
});
|
|
261
261
|
});
|
|
262
262
|
|
|
263
|
-
|
|
263
|
+
// 30s timeout — prevents hanging on network issues
|
|
264
|
+
req.setTimeout(30000, () => {
|
|
265
|
+
req.destroy(new Error('Request timed out after 30s. Check server/proxy status.'));
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
req.on('error', (err) => {
|
|
269
|
+
if (err.code === 'ECONNRESET') {
|
|
270
|
+
reject(new Error('Connection reset by server. Causes: (1) Reverse proxy body size limit, (2) Server rejected upload, (3) Network interruption. Original: ' + err.message));
|
|
271
|
+
} else {
|
|
272
|
+
reject(err);
|
|
273
|
+
}
|
|
274
|
+
});
|
|
264
275
|
req.write(data);
|
|
265
276
|
req.end();
|
|
266
277
|
});
|
|
@@ -485,11 +496,18 @@ function commandServe() {
|
|
|
485
496
|
process.on('SIGINT', () => {
|
|
486
497
|
console.log('\n[gsd-reader] Shutting down...');
|
|
487
498
|
watcher.close();
|
|
499
|
+
// Force-terminate all WebSocket clients immediately
|
|
500
|
+
wss.clients.forEach(client => client.terminate());
|
|
488
501
|
wss.close();
|
|
489
502
|
server.close(() => {
|
|
490
503
|
console.log('[gsd-reader] Goodbye!');
|
|
491
504
|
process.exit(0);
|
|
492
505
|
});
|
|
506
|
+
// Safety net: force exit after 2s if connections still linger
|
|
507
|
+
setTimeout(() => {
|
|
508
|
+
console.log('[gsd-reader] Force exit (connections still open)');
|
|
509
|
+
process.exit(0);
|
|
510
|
+
}, 2000).unref();
|
|
493
511
|
});
|
|
494
512
|
|
|
495
513
|
process.on('SIGTERM', () => {
|