Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Timeout doesn't behave like documented #784

@michal-billtech

Description

@michal-billtech
try {
    await Promise.race([
        new Promise((resolve, reject) => setTimeout(() => reject(new Error("my timeout")), 2000)),
        ky("https://pie.dev/status/429", {
            retry: {
                limit: 15,
            },
            timeout: 1000,
        }),
    ]);
} catch (err: unknown) {
    console.log(err); // Error: my timeout
}

The documentation says:

Timeout in milliseconds for getting a response, including any retries. Can not be greater than 2147483647. If set to false, there will be no timeout.

Reading this, I expected the code above to throw TimeoutError after 1000 ms, but rather it throws "my timeout" after 2000 ms.

What was the real intention here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions