Skip to content

Commit

Permalink
fix(server): handle request handler failures correctly with AbortSignal
Browse files Browse the repository at this point in the history
  • Loading branch information
ardatan committed Mar 11, 2024
1 parent 2c30c51 commit 3f31f2d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/old-trains-remain.md
@@ -0,0 +1,5 @@
---
"@whatwg-node/server": patch
---

Handle errors from async request handlers correctly in case of AbortSignal
10 changes: 7 additions & 3 deletions packages/server/src/utils.ts
Expand Up @@ -565,9 +565,13 @@ export function handleAbortSignalAndPromiseResponse(
abortSignal.addEventListener('abort', function abortSignalFetchErrorHandler() {
deferred$.reject(new DOMException('Aborted', 'AbortError'));
});
response$.then(function fetchSuccessHandler(res) {
deferred$.resolve(res);
});
response$
.then(function fetchSuccessHandler(res) {
deferred$.resolve(res);
})
.catch(function fetchErrorHandler(err) {
deferred$.reject(err);
});
return deferred$.promise;
}
return response$;
Expand Down

0 comments on commit 3f31f2d

Please sign in to comment.