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

fix: correct support for AbortSignal:timeout() #2388

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
chore: use const for TimeoutError code in tests
  • Loading branch information
katsanva committed Nov 3, 2024
commit 0f49611aa7c148c1ef6d2be3147404b03c726366
5 changes: 3 additions & 2 deletions test/abort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,14 +325,15 @@ test('support setting the signal as a default option', async t => {
t.true(signalHandlersRemoved(), 'Abort signal event handlers not removed');
});

const timeoutErrorCode = 23;
// See https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal/timeout_static
test('support AbortSignal.timeout()', async t => {
const signal = AbortSignal.timeout(1);

const p = got('http://example.com', {signal});

await t.throwsAsync(p, {
code: 23,
code: timeoutErrorCode,
message: 'The operation was aborted due to timeout',
});
});
Expand All @@ -347,7 +348,7 @@ test('support AbortSignal.timeout() without user abort', async t => {
const p = got('http://example.com', {signal});

await t.throwsAsync(p, {
code: 23,
code: timeoutErrorCode,
message: 'The operation was aborted due to timeout',
});

Expand Down