[0.81] Prevent partially initialized TurboModules during shutdown - #16369
Open
Khalef Hosany (Khalef1) wants to merge 1 commit into
Open
[0.81] Prevent partially initialized TurboModules during shutdown#16369Khalef Hosany (Khalef1) wants to merge 1 commit into
Khalef Hosany (Khalef1) wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: e5dad4bf-4f71-43ee-aa7f-d2f11d43121e
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents lazy TurboModules from being returned with uninitialized runtime-dependent state during shutdown.
Changes:
- Validates and retains the JSI runtime during module registration.
- Releases the temporary runtime handle afterward.
- Adds a patch change file.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
vnext/Microsoft.ReactNative/TurboModulesProvider.cpp |
Guards and stabilizes TurboModule initialization. |
change/react-native-windows-c5366f79-8343-45d0-9916-3f13b872c4d8.json |
Records the patch release note. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+39
to
+40
| TurboModuleBuilder(const IReactContext &reactContext, IInspectable runtimeHandle) noexcept | ||
| : m_reactContext(reactContext), m_runtimeHandle(std::move(runtimeHandle)) {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Type of Change
Why
Watson reports an access violation in
BlobTurboModule::CreateFromPartsbecausem_resourceis null. This regressed after #16237: during instance teardown,REACT_INITis skipped when the runtime handle is null, but the lazy TurboModule can still be returned to JavaScript. The module is then callable without its initializer having populated its state. The same partial-initialization pattern can affect other lazy TurboModules.What
react-native-windowspatch change file.Screenshots
Not applicable.
Testing
yarn format:verifyyarn beachball check --branch origin/0.81-stableChangelog
Should this change be included in the release notes: yes
Prevent lazy TurboModules from being created without a runtime during shutdown.
Microsoft Reviewers: Open in CodeFlow