summaryrefslogtreecommitdiffstats
path: root/test/fetch/issue-2171.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/fetch/issue-2171.js')
-rw-r--r--test/fetch/issue-2171.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/fetch/issue-2171.js b/test/fetch/issue-2171.js
new file mode 100644
index 0000000..b04ae0e
--- /dev/null
+++ b/test/fetch/issue-2171.js
@@ -0,0 +1,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
+ }
+ )
+})