Fix: ReactDOM.preloadModule crashes with repeated custom as value#36454
Fix: ReactDOM.preloadModule crashes with repeated custom as value#36454jshaofa-ui wants to merge 1 commit into
Conversation
The repeated custom-`as` path checks `moduleUnknownResources` but then reads the bucket from `unknownResources`, so the bucket can be undefined. Fixed by reading from `moduleUnknownResources` instead of `unknownResources` on line 6555 of ReactFizzConfigDOM.js. Fixes facebook#36440
|
Hi @jshaofa-ui! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. 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@meta.com. Thanks! |
Summary
Fixes a crash in
ReactDOM.preloadModule()when called multiple times with the same customasvalue (e.g.,as: 'serviceworker').Root Cause
In
ReactFizzConfigDOM.jsline 6555, the code checksresumableState.moduleUnknownResources.hasOwnProperty(as)but then reads fromresumableState.unknownResources[as]— which isundefinedfor customastypes since they're stored inmoduleUnknownResources, notunknownResources.Fix
One-word change:
unknownResources→moduleUnknownResourceson line 6555.Before:
After:
Reproduction
The second call crashes with:
TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')Fixes #36440