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

chore: simplify creation of fetch error #2327

Closed
wants to merge 987 commits into from
Closed

chore: simplify creation of fetch error #2327

wants to merge 987 commits into from

Conversation

fedyk
Copy link

@fedyk fedyk commented Oct 10, 2023

Simplify creation of fetch error

This relates to the way how fetch error is created. TypeError accept cause in constructor, so Object.assign can be removed.

KhafraDev and others added 30 commits January 18, 2023 21:40
* Fix default fetch parameters

* Preserve existing behavior with 300 second timeout if not defined

* Add test for 300 second timeout as default

* Cleanup old unused tests

* Simplify how fetch utilizes timeouts from agent
* wpt: make runner more resilient

* wpt: cleaner exit, hopefully
* Make test pass in v19.x

Signed-off-by: Matteo Collina <hello@matteocollina.com>

* fixup

Signed-off-by: Matteo Collina <hello@matteocollina.com>

* enable v19

Signed-off-by: Matteo Collina <hello@matteocollina.com>

* fixup

Signed-off-by: Matteo Collina <hello@matteocollina.com>

* fixup

Signed-off-by: Matteo Collina <hello@matteocollina.com>

* github CI timeout

Signed-off-by: Matteo Collina <hello@matteocollina.com>

Signed-off-by: Matteo Collina <hello@matteocollina.com>
Signed-off-by: Matteo Collina <hello@matteocollina.com>

fix #1890
* feat: expose content-type parser

* fix: add docs
kyrylodolynskyi and others added 9 commits October 5, 2023 14:52
Bumps [sinon](https://github.com/sinonjs/sinon) from 15.2.0 to 16.1.0.
- [Release notes](https://github.com/sinonjs/sinon/releases)
- [Changelog](https://github.com/sinonjs/sinon/blob/main/docs/changelog.md)
- [Commits](sinonjs/sinon@v15.2.0...v16.1.0)

---
updated-dependencies:
- dependency-name: sinon
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* feat: respect  Node.js flag

* add test

* cleaner test

* fix test

* update docs

* revert empty space

* remove already default value

* add

* don't use `globalThis.fetch` to pass test in Node.js 16

* add test under `test/fetch`

* fix lint

* import from `undici-fetch`

* use correct paths, use `request` for pure undici test

* fix Node.js 14 test
@fedyk fedyk changed the title Simplify fetch error creation Simplify creation of fetch error Oct 10, 2023
@fedyk fedyk changed the title Simplify creation of fetch error chore: simplify creation of fetch error Oct 10, 2023
@KhafraDev
Copy link
Member

A few things:

  • this will drop support for node v16.8 (or make the error entirely useless). Not really an issue but the README should be changed.
  • there's at least one more place where this pattern is used, I think in lib/fetch/body.js? It should be changed there also.

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.

I don't think we should be landing this without bumping a major.

@mcollina mcollina added the semver-major Features or fixes that will be included in the next semver major release label Oct 11, 2023
@codecov-commenter
Copy link

codecov-commenter commented Oct 11, 2023

Codecov Report

Attention: 424 lines in your changes are missing coverage. Please review.

Comparison is base (61246a5) 90.34% compared to head (f541cb6) 85.42%.
Report is 250 commits behind head on next.

Additional details and impacted files
@@            Coverage Diff             @@
##             next    #2327      +/-   ##
==========================================
- Coverage   90.34%   85.42%   -4.93%     
==========================================
  Files          70       76       +6     
  Lines        6038     6867     +829     
==========================================
+ Hits         5455     5866     +411     
- Misses        583     1001     +418     
Files Coverage Δ
index-fetch.js 100.00% <100.00%> (ø)
lib/api/abort-signal.js 100.00% <100.00%> (ø)
lib/api/api-connect.js 97.87% <100.00%> (+0.09%) ⬆️
lib/api/api-stream.js 100.00% <100.00%> (ø)
lib/cache/symbols.js 100.00% <100.00%> (ø)
lib/cookies/index.js 100.00% <100.00%> (ø)
lib/cookies/parse.js 90.90% <100.00%> (-0.30%) ⬇️
lib/core/connect.js 80.00% <100.00%> (-13.43%) ⬇️
lib/core/symbols.js 100.00% <ø> (ø)
lib/dispatcher-base.js 91.57% <100.00%> (+0.08%) ⬆️
... and 33 more

... and 3 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@metcoder95 metcoder95 changed the base branch from main to next October 11, 2023 07:45
@metcoder95
Copy link
Member

metcoder95 commented Oct 11, 2023

Changed the branch but it seems next needs to be rebased

@fedyk
Copy link
Author

fedyk commented Oct 11, 2023

@KhafraDev thanks for your comment. I've adjusted lib/fetch/body.js and lib/fetch/response.js as well.

As for changes in README, I didn't get the point with dropping support for node v16.8. If it is critical for this MR, please elaborate 🙂

@mcollina
Copy link
Member

This commit should target the next branch

@mcollina
Copy link
Member

I merged main in next

@KhafraDev
Copy link
Member

As for changes in README, I didn't get the point with dropping support for node v16.8. If it is critical for this MR, please elaborate

error.cause was added in node v16.9, at least according to mdn. On node v16.8, which is currently supported by undici, the error message will be completely useless with this change, essentially dropping support for it IMO.

build/wasm.js Dismissed Show dismissed Hide dismissed
// https://w3c.github.io/webappsec-subresource-integrity/#grammardef-hash-with-options
// https://www.w3.org/TR/CSP2/#source-list-syntax
// https://www.rfc-editor.org/rfc/rfc5234#appendix-B.1
const parseHashWithOptions = /((?<algo>sha256|sha384|sha512)-(?<hash>[A-z0-9+/]{1}.*={0,2}))( +[\x21-\x7e]?)?/i

Check warning

Code scanning / CodeQL

Overly permissive regular expression range Medium

Suspicious character range that is equivalent to [A-Z[]^_`a-z].
@fedyk fedyk mentioned this pull request Oct 15, 2023
7 tasks
@fedyk
Copy link
Author

fedyk commented Oct 15, 2023

As for changes in README, I didn't get the point with dropping support for node v16.8. If it is critical for this MR, please elaborate

error.cause was added in node v16.9, at least according to mdn. On node v16.8, which is currently supported by undici, the error message will be completely useless with this change, essentially dropping support for it IMO.

You are right - cause is supported since v16.9.0

@fedyk
Copy link
Author

fedyk commented Oct 15, 2023

I've created a new clean MR for the changes #2347. This one got glutted

@fedyk fedyk closed this Oct 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-major Features or fixes that will be included in the next semver major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.