replywizard-whatsapp-mcp 0.2.3 → 0.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replywizard-whatsapp-mcp",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Local MCP server that exposes WhatsApp Web (read + value tools) to AI clients via the Reply Wizard Chrome extension.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/daemon.js CHANGED
@@ -125,8 +125,16 @@ export function createDaemon({
125
125
  });
126
126
  transport.onclose = () => { if (sid && sessions.delete(sid)) publishClients(); };
127
127
  const server = createMcpServer(bridge);
128
- await server.connect(transport);
129
- await transport.handleRequest(req, res, body);
128
+ try {
129
+ await server.connect(transport);
130
+ await transport.handleRequest(req, res, body);
131
+ } catch (e) {
132
+ // A rejected initialize (e.g. DNS-rebinding block, malformed body) must not
133
+ // leak the freshly-connected Server/transport. close() also fires onclose →
134
+ // session cleanup if it had already registered. Re-throw so handle() 500s.
135
+ try { await transport.close(); } catch { /* noop */ }
136
+ throw e;
137
+ }
130
138
  }
131
139
 
132
140
  async function handle(req, res) {
package/src/wsServer.js CHANGED
@@ -330,7 +330,13 @@ export class ExtensionBridge {
330
330
  }
331
331
 
332
332
  _send(obj) {
333
- if (this.socket && this.socket.readyState === this.socket.OPEN) this.socket.send(JSON.stringify(obj));
333
+ // Never throw out of a send: if the socket is closing mid-write, socket.send can
334
+ // throw and would otherwise unwind _dispatch, leaking a lane slot until timeout.
335
+ // Swallowing here is safe — the per-action timeout and _failAll(on-disconnect)
336
+ // both recover the in-flight entry.
337
+ try {
338
+ if (this.socket && this.socket.readyState === this.socket.OPEN) this.socket.send(JSON.stringify(obj));
339
+ } catch { /* socket closing; recovery handled by timeout / disconnect */ }
334
340
  }
335
341
 
336
342
  // Set the list of connected MCP clients (called by the daemon on session