sindresorhus / got

🌐 Human-friendly and powerful HTTP request library for Node.js
MIT License
14.32k stars 938 forks source link

Abort error name is incorrect #2371

Open tal-rofe98 opened 3 months ago

tal-rofe98 commented 3 months ago

Describe the bug

I have this simple script:

import got from "got";

await got("https://google.com", { signal: AbortSignal.timeout(1) }).catch((error) => console.log(error.name));

Obviously it times out immediately.

Actual behavior

The log is AbortError

...

Expected behavior

Should be TimeoutError. When I do:

await fetch("https://google.com", { signal: AbortSignal.timeout(1) }).catch((error) =>
    console.log(error.name),
);

It prints TimeoutError ...