-
-
Notifications
You must be signed in to change notification settings - Fork 533
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(react-native): import "node:events" lazily #1858
Conversation
private createContext(): SetupServerInternalContext { | ||
return { | ||
get nodeEvents() { | ||
return import('node:events') |
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.
I think this Promise should only ever fire once. I'm not sure if I'm structuring this correctly but the intention is to try to import this module once so each outgoing request (request listener) doesn't pend on this import, increasing the response time).
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.
I think this makes sense, hopefully that helps work around the issues with this api in react-native like environments.
Re the import promise only being called once, I think it should resolve immediately since import
calls are cached as far as I know, so that should be fine
@mattcosta7 Can we release a beta version with this change? I could try and give feedback. |
@DogukanTansuk, you can always install a package from a particular branch/commit. I believe all modern package managers support that (NPM, Yarn, PNPM). You can install it that way and let me know if this fixes the issue? Thanks! |
I'm promoting this to a release candidate because the change is backward-compatible and has no effect on the existing |
Released: v2.0.7 🎉This has been released in v2.0.7! Make sure to always update to the latest version ( Predictable release automation by @ossjs/release. |
Changes
context
on theSetupServerApi
class.context.nodeEvents()
getter that lazily importsnode:events
and returnsundefined
if the import failed (e.g. in React Native).AbortSignal
max listeners handling from the request listener to a private method of theSetupServerApi
class. Makes it fail-fast.