-
Notifications
You must be signed in to change notification settings - Fork 15k
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: allow reading body from non-2xx responses in net.request #21055
fix: allow reading body from non-2xx responses in net.request #21055
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I'd love to get a test for this before we merge.
Hm, looks like the tests are consistently failing now. Perhaps this had some unintended consequences? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RC until CI is green
Relevant test case failures are corrected, but each time rebase to master some of tests are failing inconsistently, not sure if it's actually related tests & how to fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks! @nornagon can you review the test code style.
spec-main/api-net-spec.ts
Outdated
return | ||
} | ||
|
||
expect(requestResponseEventEmitted).to.equal(true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Calling expect()
from an event / callback will result in the entire test process being aborted, instead of just failing the test. Please refactor similarly to https://github.com/electron/electron/pull/21265/files#diff-c31378831f4597a16ed943c2f7060323R566
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is mostly copy-paste from existing test cases like https://github.com/electron/electron/blob/master/spec-main/api-net-spec.ts#L337 fyi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, these changed with #21265
Release Notes Persisted
|
I was unable to backport this PR to "7-1-x" cleanly; |
I was unable to backport this PR to "8-x-y" cleanly; |
* fix(urlrequest): allow non-2xx repsponse results - closes #21046 * test(net): add test cases to verify non-2xx body * test(session): update spec to match clientrequest behavior * test(net): update test cases to match clientrequest behavior * spec: clean up async net spec
@MarshallOfSound has manually backported this PR to "8-x-y", please check out #21285 |
* fix(urlrequest): allow non-2xx repsponse results - closes #21046 * test(net): add test cases to verify non-2xx body * test(session): update spec to match clientrequest behavior * test(net): update test cases to match clientrequest behavior * spec: clean up async net spec
* fix(urlrequest): allow non-2xx repsponse results - closes #21046 * test(net): add test cases to verify non-2xx body * test(session): update spec to match clientrequest behavior * test(net): update test cases to match clientrequest behavior * spec: clean up async net spec
#21295) * fix: allow reading body from non-2xx responses in net.request (#21055) * fix(urlrequest): allow non-2xx repsponse results - closes #21046 * test(net): add test cases to verify non-2xx body * test(session): update spec to match clientrequest behavior * test(net): update test cases to match clientrequest behavior * spec: clean up async net spec * Update api-session-spec.js * chore: fixup test as per original PR to master
Description of Change
Context: https://cs.chromium.org/chromium/src/services/network/public/cpp/simple_url_loader.h?dr=C&g=0&l=262-276
SimpleURLLoader
by default do not allow non-2xx http response as results, raisesERR_HTTP_RESPONSE_CODE_FAILURE
and it makes attempt to read response body for those response not possible in net module's clientrequest.This PR changes urlloader configuration to allow - this behavior matches to previous
net
module implementation, as well as browser native likefetch
.Checklist
npm test
passesRelease Notes
Notes: Fixed net module request raises error when non-2xx response received.