Skip to content

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

Closed
@ayonli

Description

@ayonli

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.

Metadata

Metadata

Assignees

Labels

ext/httprelated to ext/http

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions