-
Notifications
You must be signed in to change notification settings - Fork 45.7k
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
Retain module init errors instead of retrying #20429
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit e54e897:
|
Details of bundled changes.Comparing: cdfde3a...e54e897 react-server-dom-relay
react-server-native-relay
react-client
react-server-dom-webpack
Size changes (stable) |
Since requiring a module doesn't always rethrow the same error as the first time, we save the error so that it rethrows in all cases. This is not fool proof because if a different module requires the same thing that errored, then it'll still read an uninitialized version but at least the first error hopefully propagated.
e909338
to
e54e897
Compare
Another thing I'm not sure about is why this gets logged to the console twice in prod. |
Hi @sebmarkbage! Thank you for your pull request. We require contributors to sign our Contributor License Agreement, and yours needs attention. You currently have a record in our system, but the CLA is no longer valid, and will need to be resubmitted. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
Since requiring a module doesn't always rethrow the same error as the first time, we save the error so that it rethrows in all cases.
The downside of this is that pause on uncaught exceptions doesn't work anymore for module init errors. We could potentially try the invokeGuardedCallback thing here.
This is not fool proof because if a different module requires the same thing that errored, then it'll still read an uninitialized version but at least the first error hopefully propagated.
Unfortunately this is still not enough because Fast Refresh can grab a reference to the module exports directly. This then registers the already failed export and then rerenders React with the failed export. Something about how this works also makes this a race condition and the order of errors can change as a result.