fix: prevent streamable http wite after end from crashing the node process (#933)
This commit is contained in:
parent
b28c297184
commit
24b3972931
1 changed files with 15 additions and 0 deletions
|
|
@ -303,6 +303,11 @@ export class StreamableHTTPServerTransport implements Transport {
|
|||
res.on("close", () => {
|
||||
this._streamMapping.delete(this._standaloneSseStreamId);
|
||||
});
|
||||
|
||||
// Add error handler for standalone SSE stream
|
||||
res.on("error", (error) => {
|
||||
this.onerror?.(error as Error);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -334,6 +339,11 @@ export class StreamableHTTPServerTransport implements Transport {
|
|||
}
|
||||
});
|
||||
this._streamMapping.set(streamId, res);
|
||||
|
||||
// Add error handler for replay stream
|
||||
res.on("error", (error) => {
|
||||
this.onerror?.(error as Error);
|
||||
});
|
||||
} catch (error) {
|
||||
this.onerror?.(error as Error);
|
||||
}
|
||||
|
|
@ -520,6 +530,11 @@ export class StreamableHTTPServerTransport implements Transport {
|
|||
this._streamMapping.delete(streamId);
|
||||
});
|
||||
|
||||
// Add error handler for stream write errors
|
||||
res.on("error", (error) => {
|
||||
this.onerror?.(error as Error);
|
||||
});
|
||||
|
||||
// handle each message
|
||||
for (const message of messages) {
|
||||
this.onmessage?.(message, { authInfo, requestInfo });
|
||||
|
|
|
|||
Loading…
Reference in a new issue