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 +1 -1
- package/src/daemon.js +10 -2
- package/src/wsServer.js +7 -1
package/package.json
CHANGED
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
|
-
|
|
129
|
-
|
|
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
|
|
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
|