Skip to content

Commit

Permalink
Make the fetch() abort test pass locally, on Linux and Mac, Node 18 a…
Browse files Browse the repository at this point in the history
…nd 19 (nodejs#1927)

Signed-off-by: Matteo Collina <[email protected]>
  • Loading branch information
mcollina authored and metcoder95 committed Jul 21, 2023
1 parent f9104f4 commit ab96024
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions test/fetch/abort.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,14 @@ test('allows aborting with custom errors', { skip: semver.satisfies(process.vers
t.teardown(server.close.bind(server))
await once(server, 'listening')

t.test('Using AbortSignal.timeout without cause', { skip: semver.satisfies(process.version, '>= 19.0.0') }, async (t) => {
await t.rejects(
fetch(`http://localhost:${server.address().port}`, {
signal: AbortSignal.timeout(50)
}),
{
name: 'TimeoutError',
code: DOMException.TIMEOUT_ERR
}
)
})

t.test('Using AbortSignal.timeout with cause', { skip: semver.satisfies(process.version, '< 19.0.0') }, async (t) => {
t.test('Using AbortSignal.timeout with cause', async (t) => {
t.plan(2)

try {
await fetch(`http://localhost:${server.address().port}`, {
signal: AbortSignal.timeout(50)
})
t.fail('should throw')
} catch (err) {
if (err.name === 'TypeError') {
const cause = err.cause
Expand Down

0 comments on commit ab96024

Please sign in to comment.