Avoid proxying React modules through workUnitStore (#85486)#8
Avoid proxying React modules through workUnitStore (#85486)#8MitchLewis930 wants to merge 1 commit intopr_038_beforefrom
Conversation
Today the `captureOwnerStack()` function is provided to shared utilities through an AsyncLocalStorage that scopes the method from the appropriate React instance. This is so that external code like patches to sync IO methods can still generate errors with the appropriate React owner information even when the patched code itself is not bundled and can be called from etiher SSR or RSC contexts. This works but it makes plumbing the React instances around tricky. There is a simpler way. Most of the time you can just try both React's. If one gives you a non-null/undefined result then you know you are in that scope. If neither do then you're outside a React scope altogether. In this change I remove `captureOwnerStack()` from the workUnitStore types and just call it from the shared server runtime which gives even external code access to the appropriate React instances for bundled code
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
|||||||||
User description
PR_038
PR Type
Enhancement
Description
Remove
captureOwnerStackfrom workUnitStore interfaceCreate new
runtime-reacts.externalmodule for React instance registrationSimplify React module access by registering instances directly
Update console patching to use registered React instances instead of callbacks
Eliminate AsyncLocalStorage proxying of React modules through workUnitStore
Diagram Walkthrough
File Walkthrough
7 files
Remove captureOwnerStack from PrerenderStoreModernCommonNew module for React instance registration and retrievalRegister React instances instead of cache signal gettersRemove captureOwnerStack assignments from prerender storesRemove captureOwnerStack from all prerender store instancesRefactor to use registered React instances for cache signalsUse registered React instances for owner stack capture2 files
Update test to use new React registration APIAdd runtime-reacts.external to NFT file list