replywizard-whatsapp-mcp 0.2.2 → 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.2",
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/connector.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  // connector.js — stdio↔daemon proxy for MCP clients that only speak stdio (WS-A2).
2
3
  //
3
4
  // Clients that support HTTP transport connect to the daemon directly
package/src/daemon.js CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  // daemon.js — long-lived multi-client MCP daemon (Option A, WS-A1).
2
3
  //
3
4
  // The original index.js binds ONE stdio client and ONE extension WebSocket per
@@ -124,8 +125,16 @@ export function createDaemon({
124
125
  });
125
126
  transport.onclose = () => { if (sid && sessions.delete(sid)) publishClients(); };
126
127
  const server = createMcpServer(bridge);
127
- await server.connect(transport);
128
- 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
+ }
129
138
  }
130
139
 
131
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