fixed the error handling in async call

This commit is contained in:
Shane 2025-05-18 23:33:19 -07:00
commit 7df1936b3c
No known key found for this signature in database
GPG key ID: 4C057F3D5CBFE209

View file

@ -266,7 +266,6 @@ app.get("/stdio", async (req, res) => {
// Create a stderr handler that checks connection state // Create a stderr handler that checks connection state
const stderrHandler = (chunk: Buffer) => { const stderrHandler = (chunk: Buffer) => {
try {
// Only send if the transport exists in our map (meaning it's still active) // Only send if the transport exists in our map (meaning it's still active)
if (webAppTransports.has(webAppTransport.sessionId)) { if (webAppTransports.has(webAppTransport.sessionId)) {
webAppTransport.send({ webAppTransport.send({
@ -275,12 +274,12 @@ app.get("/stdio", async (req, res) => {
params: { params: {
content: chunk.toString(), content: chunk.toString(),
}, },
}); })
} .catch((error: any) => {
} catch (error: any) { console.error(`Error sending stderr data to client: ${error.message}`);
console.log(`Error sending stderr data to client: ${error.message}`);
// If we hit an error sending, clean up the transport // If we hit an error sending, clean up the transport
webAppTransports.delete(webAppTransport.sessionId); webAppTransports.delete(webAppTransport.sessionId);
});
} }
}; };