Skip to content

iOS RCTFatal truncation preventing debugging #22530

@zackdotcomputer

Description

@zackdotcomputer

Environment

React Native Environment Info:

    System:
      OS: macOS 10.14.1
      CPU: x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
      Memory: 23.93 MB / 16.00 GB
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 11.2.0 - /usr/local/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.4.1 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    SDKs:
      iOS SDK:
        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
      Android SDK:
        Build Tools: 23.0.1, 27.0.3, 28.0.2
        API Levels: 23, 25, 26, 27, 28
    IDEs:
      Android Studio: 3.2 AI-181.5540.7.32.5056338
      Xcode: 10.1/10B61 - /usr/bin/xcodebuild
    npmPackages:
      @types/react: ^16.4.7 => 16.4.9 
      @types/react-native: ^0.56.4 => 0.56.7 
      react: 16.4.1 => 16.4.1 
      react-native: 0.56.0 => 0.56.0 
    npmGlobalPackages:
      create-react-native-app: 2.0.2

Summary

TLDR; The very low "max message length" of 75 at this line in RCTAssert.m renders RCTFatal errors very difficult to debug.

Description

What we're seeing is that errors captured by the iOS built-in crash analytics and by Sentry.io are using the NSException.message to describe the message and discarding the name value. As such, we're only seeing the 75 character truncated value. Given how much of that string is dedicated to boilerplate information about the exception, we wind up with exception logs like RCTFatalException: Exception '*** -[__NSArrayM setObject:atIndexedSubscript:]: object cannot be nil' was thrown while invokin... that truncate just before the actually useful information for debugging would be printed.

There isn't an especially compelling reason that I know of for keeping this value truncated as short as 75 characters. (Indeed, IMO there isn't really a reason to truncate it at all, but I expect there are cases that demand that that I'm not aware of.) I'm going to make a branch and pull-request that will both extend this truncation length and add information to the userinfo dictionary on the exception.

Reproducible Demo

Cause any exception and view the value in the RCTFatalException that is thrown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions