Skip to content
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

Deno.serve: request.signal is aborted even though the response finished successfully #27005

Open
ayonli opened this issue Nov 22, 2024 · 3 comments

Comments

@ayonli
Copy link

ayonli commented Nov 22, 2024

Version: Deno 2.1.1

Example:

Deno.serve((req: Request) => {
    req.signal.addEventListener("abort", () => {
        console.log("Request aborted on the server side:", req.signal.aborted);
    });

    return new Response("Hello, World!");
});

const constructor = new AbortController();
const { signal } = constructor;

const res = await fetch("http://localhost:8000", { signal });
console.log(await res.text());

console.log("Request aborted on the client side:", signal.aborted);

Prints:

Request aborted on the server side: true
Hello, World!
Request aborted on the client side: false

This is awkward, and may even lead to potential bugs.

Bun doesn't seem to have this problem.

@nathanwhit
Copy link
Member

cc @littledivy

@nathanwhit nathanwhit added the bug Something isn't working correctly label Nov 22, 2024
@littledivy
Copy link
Member

This has been intended behavior ever since request abort signals were introduced in Deno.serve. All request signals are aborted when it completes (marking them as completed).

@nathanwhit nathanwhit removed the bug Something isn't working correctly label Nov 23, 2024
@ayonli ayonli changed the title Deno.serve: request.signal is aborted even the response finished successfully Deno.serve: request.signal is aborted even though the response finished successfully Nov 23, 2024
@ayonli
Copy link
Author

ayonli commented Nov 23, 2024

This has been intended behavior ever since request abort signals were introduced in Deno.serve. All request signals are aborted when it completes (marking them as completed).

I just updated the example, please check again the oddness of this design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants