git-watchtower 1.14.9 → 1.14.10

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/server/web.js +22 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "git-watchtower",
3
- "version": "1.14.9",
3
+ "version": "1.14.10",
4
4
  "description": "Terminal-based Git branch monitor with activity sparklines and optional dev server with live reload",
5
5
  "main": "bin/git-watchtower.js",
6
6
  "bin": {
package/src/server/web.js CHANGED
@@ -63,6 +63,9 @@ class WebDashboardServer {
63
63
  this.pushInterval = null;
64
64
  this.lastPushedJson = '';
65
65
 
66
+ /** @type {Set<import('net').Socket>} Raw TCP sockets, tracked so stop() can force-close them */
67
+ this._sockets = new Set();
68
+
66
69
  // Multi-project support (populated by coordinator)
67
70
  /** @type {Map<string, Object>} */
68
71
  this.projects = new Map();
@@ -239,6 +242,14 @@ class WebDashboardServer {
239
242
  this._handleRequest(req, res);
240
243
  });
241
244
 
245
+ // Track raw TCP sockets so stop() can force-destroy lingering
246
+ // connections (long-lived SSE, paused browsers, proxied clients)
247
+ // instead of waiting for a full TCP FIN_WAIT2 timeout.
248
+ this.server.on('connection', (/** @type {import('net').Socket} */ socket) => {
249
+ this._sockets.add(socket);
250
+ socket.once('close', () => this._sockets.delete(socket));
251
+ });
252
+
242
253
  this.server.on('error', (/** @type {Error & {code?: string}} */ err) => {
243
254
  if (err.code === 'EADDRINUSE' && retries < MAX_PORT_RETRIES) {
244
255
  retries++;
@@ -270,7 +281,7 @@ class WebDashboardServer {
270
281
  this.pushInterval = null;
271
282
  }
272
283
 
273
- // Close all SSE connections
284
+ // End SSE response streams gracefully (sends FIN).
274
285
  for (const client of this.clients) {
275
286
  try { client.end(); } catch (e) { /* SSE client may already be disconnected */ }
276
287
  }
@@ -278,6 +289,16 @@ class WebDashboardServer {
278
289
 
279
290
  if (this.server) {
280
291
  this.server.close();
292
+
293
+ // Force-destroy any TCP sockets that didn't close after the
294
+ // graceful end() above. Without this, a paused browser, a
295
+ // suspended tab, or a slow proxy can pin server.close() for the
296
+ // full TCP FIN_WAIT2 timeout (typically 60 s), delaying shutdown.
297
+ for (const socket of this._sockets) {
298
+ try { socket.destroy(); } catch (e) { /* ignore */ }
299
+ }
300
+ this._sockets.clear();
301
+
281
302
  this.server = null;
282
303
  }
283
304
  }