Skip to content

Commit

Permalink
fix(fetch): makeNetworkError called twice when httpNetworkFetch run e…
Browse files Browse the repository at this point in the history
…rror (nodejs#1353)
  • Loading branch information
meixg authored and crysmags committed Feb 27, 2024
1 parent 22d28eb commit 16a0ebc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/fetch/index.js
Expand Up @@ -2029,7 +2029,7 @@ async function httpNetworkFetch (

fetchParams.controller.terminate(error)

reject(makeNetworkError(error))
reject(error)
}
}
))
Expand Down
10 changes: 10 additions & 0 deletions test/fetch/client-fetch.js
Expand Up @@ -332,3 +332,13 @@ test('post FormData with File', (t) => {
t.ok(/filename123/.test(result))
})
})

test('invalid url', async (t) => {
t.plan(1)

try {
await fetch('http://invalid')
} catch (e) {
t.match(e.cause.message, 'invalid')
}
})

0 comments on commit 16a0ebc

Please sign in to comment.