Skip to content

Commit 166e9b5

Browse files
ronagcrysmags
authored andcommitted
fix: only throw error responses (nodejs#1076)
Fixes: nodejs#1072
1 parent 74a2f9d commit 166e9b5

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

lib/fetch/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ async function fetch (...args) {
171171

172172
// 3. If response is a network error, then reject p with a TypeError
173173
// and terminate these substeps.
174-
if (response.status === 0) {
174+
if (response.type === 'error') {
175175
p.reject(
176176
Object.assign(new TypeError('fetch failed'), { cause: response.error })
177177
)

test/node-fetch/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,14 +409,14 @@ describe('node-fetch', () => {
409409
})
410410
})
411411

412-
xit('should treat broken redirect as ordinary response (manual)', () => {
412+
it('should treat broken redirect as ordinary response (manual)', () => {
413413
const url = `${base}redirect/no-location`
414414
const options = {
415415
redirect: 'manual'
416416
}
417417
return fetch(url, options).then(res => {
418418
expect(res.url).to.equal(url)
419-
expect(res.status).to.equal(301)
419+
expect(res.status).to.equal(0)
420420
expect(res.headers.get('location')).to.be.null
421421
})
422422
})

0 commit comments

Comments
 (0)