Skip to content

fix: Set preventAbort to true on the pipeThrough as to work around an issue in Deno where an uncatchable exception is thrown if/when the client aborts the incoming request. #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/html_rewriter_wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,15 @@ export class HTMLRewriter {
});

// Return a response with the transformed body, copying over headers, etc
const res = new Response(body.pipeThrough(transformStream), response);
const res = new Response(
body.pipeThrough(transformStream, {
// Work around an issue in Deno where an uncatchable exception is thrown
// if/when the client aborts the incoming request.
// https://github.com/denoland/deno/issues/27715
preventAbort: true,
}),
response,
);
// If Content-Length is set, it's probably going to be wrong, since we're
// rewriting content, so remove it
res.headers.delete("Content-Length");
Expand Down
Loading