Skip to content

Commit 7df1936

Browse files
committed
fixed the error handling in async call
1 parent b9b3682 commit 7df1936

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

server/src/index.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -266,21 +266,20 @@ app.get("/stdio", async (req, res) => {
266266

267267
// Create a stderr handler that checks connection state
268268
const stderrHandler = (chunk: Buffer) => {
269-
try {
270-
// Only send if the transport exists in our map (meaning it's still active)
271-
if (webAppTransports.has(webAppTransport.sessionId)) {
272-
webAppTransport.send({
273-
jsonrpc: "2.0",
274-
method: "notifications/stderr",
275-
params: {
276-
content: chunk.toString(),
277-
},
278-
});
279-
}
280-
} catch (error: any) {
281-
console.log(`Error sending stderr data to client: ${error.message}`);
282-
// If we hit an error sending, clean up the transport
283-
webAppTransports.delete(webAppTransport.sessionId);
269+
// Only send if the transport exists in our map (meaning it's still active)
270+
if (webAppTransports.has(webAppTransport.sessionId)) {
271+
webAppTransport.send({
272+
jsonrpc: "2.0",
273+
method: "notifications/stderr",
274+
params: {
275+
content: chunk.toString(),
276+
},
277+
})
278+
.catch((error: any) => {
279+
console.error(`Error sending stderr data to client: ${error.message}`);
280+
// If we hit an error sending, clean up the transport
281+
webAppTransports.delete(webAppTransport.sessionId);
282+
});
284283
}
285284
};
286285

0 commit comments

Comments
 (0)