Skip to content

Conversation

@ehsemloh
Copy link
Contributor

@ehsemloh ehsemloh commented Jun 4, 2025

Summary:

Issue: #51664

Exceptions on non-critical path crash the app. This happened locations such as callback in setTimeout, onPress callback of <Pressable>, less defensive 3rd-parties libraries (on code level) can also crash the app on these paths.

Exception in ReactFabric::extractEvents crashes the app.

The above behaviors does not exist in older versions. In React web, exceptions on those paths are treated same way as async operations and are handled by global handler.

Changelog:

[IOS] [FIXED] - Fix crash on non-critical path

Test Plan:

  1. Callback in setTimeout:
setTimeout(() => {
  throw new Error('SWW');
}, 10000);
  1. Callback in Pressable:
<Pressable onPress={() => {
  throw new Error('SWW');
}}/>
  1. Simulated exception in ReactFabric::extractEvents
let deathCount = 0; // use this variable to pass the bootstrap

var ResponderEventPlugin = {
    _getResponder: function () {
      return responderInst;
    },
    eventTypes: eventTypes,
    extractEvents: function (
      topLevelType,
      targetInst,
      nativeEvent,
      nativeEventTarget
    ) {   
...
      if (deathCount++ === 300) { // use `===` to simulate an one-off exception, e.g., `Unsupported top level event type ...` 
        throw new Error('SWW');
      }
...

@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. labels Jun 4, 2025
@javache
Copy link
Member

javache commented Jun 30, 2025

This is intended behaviour, and should match what you saw in the old architecture.

React on web doesn't handle this case specifically either, but the default for browsers is that unhandled errors don't stop the runtime or prevent further JS execution. We're looking into matching this behaviour in the native runtime too, but this will require a more considered rollout than this PR.

@javache javache closed this Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants