Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(fetch): makeNetworkError called twice when httpNetworkFetch run error #1353

Merged
merged 1 commit into from Apr 21, 2022

Conversation

meixg
Copy link
Member

@meixg meixg commented Apr 21, 2022

fixes: nodejs/node#42804

the error will be warped again by makeNetworkError at L1751:

undici/lib/fetch/index.js

Lines 1734 to 1752 in b6a7262

try {
const { body, status, statusText, headersList } = await dispatch({ body: requestBody })
const iterator = body[Symbol.asyncIterator]()
fetchParams.controller.next = () => iterator.next()
response = makeResponse({ status, statusText, headersList })
} catch (err) {
// 10. If aborted, then:
if (err.name === 'AbortError') {
// 1. If connection uses HTTP/2, then transmit an RST_STREAM frame.
fetchParams.controller.connection.destroy()
// 2. Return the appropriate network error for fetchParams.
return makeAppropriateNetworkError(fetchParams)
}
return makeNetworkError(err)
}

@codecov-commenter
Copy link

codecov-commenter commented Apr 21, 2022

Codecov Report

Merging #1353 (88de74c) into main (b6a7262) will increase coverage by 0.11%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1353      +/-   ##
==========================================
+ Coverage   94.12%   94.24%   +0.11%     
==========================================
  Files          45       45              
  Lines        4204     4204              
==========================================
+ Hits         3957     3962       +5     
+ Misses        247      242       -5     
Impacted Files Coverage Δ
lib/fetch/index.js 80.85% <100.00%> (+0.55%) ⬆️
lib/fetch/response.js 88.00% <0.00%> (+1.33%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b6a7262...88de74c. Read the comment docs.

Copy link
Member

@ronag ronag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit d627522 into nodejs:main Apr 21, 2022
KhafraDev pushed a commit to KhafraDev/undici that referenced this pull request Jun 23, 2022
metcoder95 pushed a commit to metcoder95/undici that referenced this pull request Dec 26, 2022
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Global fetch produces unhelpful Error for ENOTFOUND
4 participants