fix: contain AbortError from aborted response body cancellation
`void resp.body?.cancel()` in streamChatEvents' finally floated a rejected promise: an aborted fetch errors the body with the abort reason, and cancel() on an errored stream rejects with it, escaping as unhandledRejection -> uncaughtException and killing pi on Escape. Await the cancel inside the existing try/catch so the rejection is actually swallowed. Adds a regression test that aborts a mocked in-flight stream and asserts no unhandled rejection is raised. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
+1
-1
@@ -359,7 +359,7 @@ async function* streamChatEvents(args: {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
void resp.body?.cancel();
|
||||
await resp.body?.cancel();
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user