blob: b04ae0e6c38da565dd60b1ed15ddd0627495900b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
'use strict'
const { fetch } = require('../..')
const { DOMException } = require('../../lib/fetch/constants')
const { once } = require('events')
const { createServer } = require('http')
const { test } = require('tap')
test('error reason is forwarded - issue #2171', { skip: !AbortSignal.timeout }, async (t) => {
const server = createServer(() => {}).listen(0)
t.teardown(server.close.bind(server))
await once(server, 'listening')
const timeout = AbortSignal.timeout(100)
await t.rejects(
fetch(`http://localhost:${server.address().port}`, {
signal: timeout
}),
{
name: 'TimeoutError',
code: DOMException.TIMEOUT_ERR
}
)
})
|