Skip to content

Commit 7cc4fcf

Browse files
authored
don't freeze urlList for opaque filtered responses (#4656)
* don't freeze urlList for opaque filtered responses * test
1 parent 55eeeb3 commit 7cc4fcf

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/web/fetch/response.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ function filterResponse (response, type) {
453453

454454
return makeFilteredResponse(response, {
455455
type: 'opaque',
456-
urlList: Object.freeze([]),
456+
urlList: [],
457457
status: 0,
458458
statusText: '',
459459
body: null

test/fetch/issue-4647.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'use strict'
2+
3+
const { createServer } = require('node:http')
4+
const { test } = require('node:test')
5+
const { fetch } = require('../..')
6+
7+
// https://github.com/nodejs/undici/issues/4647
8+
test('fetch with mode: no-cors does not hang', async (t) => {
9+
const a = createServer((req, res) => {
10+
res.writeHead(200).end()
11+
}).listen(0)
12+
13+
const b = createServer((req, res) => {
14+
res.writeHead(301, { Location: `http://localhost:${a.address().port}${req.url}` }).end()
15+
}).listen(0)
16+
17+
t.after(() => {
18+
a.close()
19+
b.close()
20+
})
21+
22+
await fetch(`http://localhost:${b.address().port}/abc`, { mode: 'no-cors' })
23+
})

0 commit comments

Comments
 (0)