Skip to content

Commit

Permalink
Fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed May 4, 2024
1 parent 2948635 commit 0dc2df4
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,20 @@ async function withServer(action: (serverUrl: URL) => Promise<void>) {
return new Response(
new ReadableStream({
start(controller) {
return new Promise<void>((resolve, reject) => {
return new Promise<void>((resolve, _reject) => {
if (signal.aborted || abortController.signal.aborted) {
return;
}
const timeoutId = setTimeout(() => {
const abortListener = () => {
clearTimeout(timeoutId);
controller.close();
resolve();
}, ms);
signal.addEventListener("abort", () => {
clearTimeout(timeoutId);
reject(new Error("Client aborted."));
});
abortController.signal.addEventListener("abort", () => {
clearTimeout(timeoutId);
reject(new Error("Client aborted."));
});
signal.removeEventListener("abort", abortListener);
abortController.signal.removeEventListener("abort", abortListener);
};
const timeoutId = setTimeout(abortListener, ms);
signal.addEventListener("abort", abortListener);
abortController.signal.addEventListener("abort", abortListener);
});
},
cancel(reason) {
Expand Down

0 comments on commit 0dc2df4

Please sign in to comment.