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 · 4 comments · May be fixed by #28371
Open

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

ayonli opened this issue Nov 22, 2024 · 4 comments · May be fixed by #28371
Assignees
Labels
ext/http related to ext/http triage required 👀 Deno team needs to make a decision if this change is desired

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.

@bartlomieju bartlomieju added ext/http related to ext/http triage required 👀 Deno team needs to make a decision if this change is desired labels Dec 6, 2024
darrachequesne added a commit to socketio/socket.io-deno that referenced this issue Jan 9, 2025
`serve()` was removed in Deno v1 (May 2020).

Release notes: https://github.com/denoland/deno/releases/v1.0.0

Related: #17

Note: the `abort` signal listener was removed because it is always triggered, even when the response is successfully sent

See also: denoland/deno#27005
@ry
Copy link
Member

ry commented Feb 24, 2025

Seems weird to me that signal.aborted is supposed to mean successfully completed. I think we should change this.

@ry ry assigned littledivy and unassigned bartlomieju Feb 24, 2025
littledivy added a commit to littledivy/deno that referenced this issue Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ext/http related to ext/http triage required 👀 Deno team needs to make a decision if this change is desired
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants