mirror of
https://github.com/upstash/context7.git
synced 2025-11-30 00:50:06 +00:00
feat: add cleanup handlers for transport and server on request close
This commit is contained in:
parent
b1947fd9ed
commit
2730926ba6
@ -320,6 +320,10 @@ async function main() {
|
||||
const transport = new StreamableHTTPServerTransport({
|
||||
sessionIdGenerator: undefined,
|
||||
});
|
||||
res.on("close", () => {
|
||||
transport.close();
|
||||
requestServer.close();
|
||||
});
|
||||
await requestServer.connect(transport);
|
||||
await transport.handleRequest(req, res);
|
||||
} else if (url === "/sse" && req.method === "GET") {
|
||||
@ -330,6 +334,8 @@ async function main() {
|
||||
// Clean up transport when connection closes
|
||||
res.on("close", () => {
|
||||
delete sseTransports[sseTransport.sessionId];
|
||||
sseTransport.close();
|
||||
requestServer.close();
|
||||
});
|
||||
await requestServer.connect(sseTransport);
|
||||
} else if (url === "/messages" && req.method === "POST") {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user