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 a bug in Node <21 that prevented the normal operation of the request coalescer #2326

Conversation

steveluscher
Copy link
Collaborator

@steveluscher steveluscher commented Mar 15, 2024

Summary

There is a bug in the version of undici that ships with Node <21 that throws an unhandled exception when the reason property of an AbortSignal is a non-object. The request coalescer hits this bug because it uses a Symbol to differentiate between an internal abort and a user abort. undici chokes on that Symbol.

In this PR we capitulate and change it to an object.

See nodejs/undici#2597 for more detail about the bug.

Test Plan

In every version of Node from 18-21, undici handles an object correctly.

~/src/solana-web3.js-git/packages/rpc$ sudo n 21 && pnpm node
     copying : node/21.7.1
   installed : v21.7.1 (with npm 10.5.0)
Welcome to Node.js v21.7.1.
Type ".help" for more information.
> await fetch('http://localhost', { signal: AbortSignal.abort({}) });
Uncaught {}
>
~/src/solana-web3.js-git/packages/rpc$ sudo n 20
     copying : node/20.11.1
   installed : v20.11.1 (with npm 10.2.4)
~/src/solana-web3.js-git/packages/rpc$ pnpm node
Welcome to Node.js v20.11.1.
Type ".help" for more information.
> await fetch('http://localhost', { signal: AbortSignal.abort({}) });
Uncaught {}
>
~/src/solana-web3.js-git/packages/rpc$ sudo n 19 && pnpm node
     copying : node/19.9.0
   installed : v19.9.0 (with npm 9.6.3)
Welcome to Node.js v19.9.0.
Type ".help" for more information.
> await fetch('http://localhost', { signal: AbortSignal.abort({}) });
Uncaught {}
>
~/src/solana-web3.js-git/packages/rpc$ sudo n 18 && pnpm node
     copying : node/18.19.1
   installed : v18.19.1 (with npm 10.2.4)
Welcome to Node.js v18.19.1.
Type ".help" for more information.
> await fetch('http://localhost', { signal: AbortSignal.abort({}) });
Uncaught {}
>

Resolves #2325.

Copy link

changeset-bot bot commented Mar 15, 2024

⚠️ No Changeset found

Latest commit: e894a4a

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@steveluscher
Copy link
Collaborator Author

steveluscher commented Mar 15, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @steveluscher and the rest of your teammates on Graphite Graphite

@steveluscher steveluscher added the automerge Merge this Pull Request automatically once CI passes label Mar 15, 2024
@mergify mergify bot merged commit 0d4a1f9 into master Mar 15, 2024
7 checks passed
@mergify mergify bot deleted the 03-15-Fix_a_bug_in_Node_21_that_prevented_the_normal_operation_of_the_request_coalescer branch March 15, 2024 19:31
Copy link
Contributor

🎉 This PR is included in version 1.91.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

Because there has been no activity on this PR for 14 days since it was merged, it has been automatically locked. Please open a new issue if it requires a follow up.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
automerge Merge this Pull Request automatically once CI passes released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[experimental] Avoid bug in fetch() with non-object reasons thrown with AbortSignal
1 participant