-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Uncatchable exception when using TransformStream
with requests.
#27715
Comments
It seems that the issue can be worked around by passing the Test code: function startServer() {
Deno.serve({ port: 8000 }, async (req) => {
const upstreamResponse = await fetch("http://localhost:8001/", req);
// Use a TransformStream to convert the response body to uppercase.
const transformStream = new TransformStream({
transform(chunk, controller) {
const decoder = new TextDecoder();
const encoder = new TextEncoder();
const chunk2 = encoder.encode(decoder.decode(chunk).toUpperCase());
controller.enqueue(chunk2);
},
cancel(reason) {
console.log("server: TransformStream cancelled:", reason);
},
});
const readable = upstreamResponse.body?.pipeThrough(transformStream, {
preventAbort: true,
});
return new Response(readable);
});
}
// Code for upstream server and client omitted for brevity.
// They're the same as the code in the issue description. |
…und an issue in Deno where an uncatchable exception is thrown if/when the client aborts the incoming request. denoland/deno#27715
…und an issue in Deno where an uncatchable exception is thrown if/when the client aborts the incoming request. denoland/deno#27715
The uncaught rejection seems happening at this line Line 2546 in b5c3f4f
This rejects |
The code below simulates a proxy server that makes a fetch() call, transforms the body, and then returns the transformed body.
When the client cancels a request, the server crashes with an uncaught exception that cannot be caught in any way.
Output:
The text was updated successfully, but these errors were encountered: