fix: close per-request server and transport in example-apps handler
The stateless /:slug/mcp handler creates a fresh McpServer and StreamableHTTPServerTransport on every request but never closed them, leaking memory under load. Register a 'close' listener (fires on both normal completion and client abort mid-SSE) to release them.
This commit is contained in:
parent
4555e800ac
commit
811a78f310
1 changed files with 5 additions and 0 deletions
|
|
@ -133,6 +133,11 @@ export class ExampleAppsModule {
|
|||
sessionIdGenerator: undefined, // Stateless: no session management
|
||||
});
|
||||
|
||||
res.on('close', () => {
|
||||
transport.close();
|
||||
server.close();
|
||||
});
|
||||
|
||||
await server.connect(transport);
|
||||
await transport.handleRequest(req, res, req.body);
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue