diff --git a/src/index.ts b/src/index.ts index 0bbc931..8f609d4 100644 --- a/src/index.ts +++ b/src/index.ts @@ -873,8 +873,8 @@ if (cluster.isPrimary) { }); } else { // ── Worker: cada uno tiene su propio McpServer singleton ── - // El mutex serializa las requests dentro de este worker (stateless, 1 request a la vez por worker) - let workerBusy: Promise = Promise.resolve(); + // Sin mutex: cada request se atiende concurrentemente dentro del worker. + // StreamableHTTPServerTransport es stateless (uno por request), sin estado compartido. async function handleMcpRequest(req: IncomingMessage, res: ServerResponse): Promise { const transport = new StreamableHTTPServerTransport({ @@ -893,16 +893,14 @@ if (cluster.isPrimary) { res.writeHead(404).end("Not found"); return; } - workerBusy = workerBusy - .then(() => handleMcpRequest(req, res)) - .catch((err) => { - console.error(`[docmost-mcp] Worker PID=${process.pid} error:`, err); - if (!res.headersSent) { - res.writeHead(500, { "Content-Type": "application/json" }).end( - JSON.stringify({ jsonrpc: "2.0", error: { code: -32603, message: String(err) }, id: null }) - ); - } - }); + handleMcpRequest(req, res).catch((err) => { + console.error(`[docmost-mcp] Worker PID=${process.pid} error:`, err); + if (!res.headersSent) { + res.writeHead(500, { "Content-Type": "application/json" }).end( + JSON.stringify({ jsonrpc: "2.0", error: { code: -32603, message: String(err) }, id: null }) + ); + } + }); }); httpServer.listen(8080, () => { diff --git a/src/lib/collaboration.ts b/src/lib/collaboration.ts index c767127..452e340 100644 --- a/src/lib/collaboration.ts +++ b/src/lib/collaboration.ts @@ -67,7 +67,7 @@ export async function updatePageContentRealtime( const timer = setTimeout(() => { if (provider) provider.destroy(); reject(new Error("Connection timeout to collaboration server")); - }, 25000); + }, 120000); const provider = new HocuspocusProvider({ url: wsUrl,