claude-code-cost 1.9.0 → 1.9.1

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/lib/net-guard.js +15 -3
  2. package/package.json +1 -1
package/lib/net-guard.js CHANGED
@@ -258,7 +258,10 @@ function createNetGuard(config = {}) {
258
258
  * `onUpgrade` is attached to both servers; a caller that attached it to the
259
259
  * returned one alone would drop every WebSocket that arrives over the other family.
260
260
  *
261
- * @param {{maxHeaderSize?: number, onUpgrade?: (req: any, socket: any, head: Buffer) => void}} [opts]
261
+ * `originPort: false` leaves the Origin check on the port it has: for a server that does not
262
+ * route through this guard's middleware, such as the hub's proxy ports.
263
+ *
264
+ * @param {{maxHeaderSize?: number, onUpgrade?: (req: any, socket: any, head: Buffer) => void, originPort?: boolean}} [opts]
262
265
  */
263
266
  function listenLoopback(app, port, onReady, opts = {}) {
264
267
  const http = require('node:http');
@@ -278,7 +281,7 @@ function createNetGuard(config = {}) {
278
281
 
279
282
  server.on('listening', () => {
280
283
  const boundPort = server.address().port;
281
- actualPort = boundPort;
284
+ if (opts.originPort !== false) actualPort = boundPort;
282
285
  // Not actualPort: the hub listens several servers through one guard, and another one can bind
283
286
  // while this one waits for its second family.
284
287
  const ready = () => { if (onReady) onReady(boundPort); };
@@ -299,7 +302,16 @@ function createNetGuard(config = {}) {
299
302
  ready();
300
303
  }
301
304
  });
302
- server.on('close', () => { try { if (secondary) secondary.close(); } catch { /* already gone */ } });
305
+ // closeAllConnections on the primary does not reach the secondary's keep-alive sockets, which
306
+ // would hold its port after the caller closed the server.
307
+ server.on('close', () => {
308
+ try {
309
+ if (secondary) {
310
+ secondary.close();
311
+ secondary.closeAllConnections?.();
312
+ }
313
+ } catch { /* already gone */ }
314
+ });
303
315
 
304
316
  server.listen(port, BIND_HOST);
305
317
  return server;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-code-cost",
3
- "version": "1.9.0",
3
+ "version": "1.9.1",
4
4
  "description": "Cost dashboard for Claude Code usage",
5
5
  "main": "server.js",
6
6
  "type": "commonjs",