Skip to content

fetch() AbortSignal.timeout() does not work as expected #1926

Closed
@mcollina

Description

@mcollina

Bug Description

It seems passing { signal: AbortSignal.timeout(50) } to fetch() is not taken into consideration.

Reproducible By

Run node test/fetch/abort.js. The AbortSignal.timeout() test should pass immediately but it waits for 30s. This is the output:

 Subtest: Allow the usage of custom implementation of AbortController
    ok 1 - should be equal
    1..1
ok 1 - Allow the usage of custom implementation of AbortController # time=6.82ms

# Subtest: allows aborting with custom errors
    # Subtest: Using AbortSignal.timeout with cause
        1..2
        ok 1 - should be equal
        ok 2 - should be equal
    ok 1 - Using AbortSignal.timeout with cause # time=30057.744ms

    # Subtest: Error defaults to an AbortError DOMException
        ok 1 - expect rejected Promise
        1..1
    ok 2 - Error defaults to an AbortError DOMException # time=7.816ms

    1..2
ok 2 - allows aborting with custom errors # time=30072.88ms

1..2
# time=30085.421ms

Expected Behavior

The fetch request should be completed in the expected timeout.

Environment

Node 18 and 19, on both Windows and Mac OS X.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfetch

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions