Repository navigation
Conversation
A blocked JS thread is not seen by the native App Hang tracker, because the UI thread stays free. JS stall tracking cannot report it either, because no JS code runs while the thread is blocked. An infinite loop in JS therefore produced no event. RNSentryJSHangTracker runs on its own native thread. Every 100 ms it schedules an empty task on the JS thread through the React Native CallInvoker. When the task does not run within jsHangTimeoutInterval (2 s by default), it samples the JS thread with the Hermes sampling profiler for 300 ms and captures an error event with the last JS stack. The tracker waits for the first answer from the JS thread before it measures, so loading the bundle is not reported as a hang. RNSentry is loaded through the interop layer, so getTurboModule is never called. The tracker gets the CallInvoker from setCallInvoker:, which React Native calls on modules that implement it. SentrySDKWrapper gets captureEvent:, because Objective-C++ cannot call the Swift SentrySDK class. The options are internal and opt-in. The sample app enables them and adds two buttons that block the JS thread.
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
Contributor
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Features
- Report JS thread hangs as errors (prototype) ([#6964](https://github.com/getsentry/sentry-react-native/pull/6964))If none of the above apply, you can opt out of this check by adding |
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.
📢 Type of change
📜 Description
This draft is a prototype for iOS on the New Architecture. A native watchdog thread schedules an empty task on the JS thread through the React Native
CallInvoker. If the task does not run withinjsHangTimeoutInterval(2 s by default), the SDK samples the JS thread with the Hermes sampling profiler and captures an error event with the JS stack.💡 Motivation and Context
An infinite loop in JS blocks the JS thread but not the UI thread, so the native App Hang tracker sends nothing. JS stall tracking cannot report it either, because no JS code runs while the thread is blocked. Closes #3460.
💚 How did you test it?
I ran the sample app on the iOS 26.1 simulator (Debug, New Architecture, static frameworks). The "Block JS thread for 5s" and "Block JS thread forever" buttons each produced one event, and the top JS frame was the function that blocked the thread. The event was sent while JS was still blocked.
yarn lint, the SDK tests,circularDepCheck, and the API report pass. One tools test (sentryMetroSerializer) also fails onmain.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
Before this is ready, it needs Android support, a Release build test with source-map symbolication, and a start path for apps that start the native SDK with
RNSentrySDK start. It also needs coordination with Hermes profiling, unit tests, and a CHANGELOG entry.