Skip to content

Downloading profile data can fail with error "RangeError: Invalid string length" #2050

@paddlefish

Description

@paddlefish

Environment

Description

If collecting a lot of profiling data, the profile-hermes command will fail.

Reproducible Demo

  • Launch a react-native app on Android
  • Open developer menu.
  • Start profiling
  • Let it run sufficiently long (Not sure how many samples are required)
  • Stop profiling
  • Download the profile.

Example

$ npx react-native --verbose profile-hermes andytest/
warn Package rn-fetch-blob contains invalid configuration: "dependency.hooks" is not allowed. Please verify it's properly linked using "react-native config" command and contact the package maintainers about this.
info Downloading a Hermes Sampling Profiler from your Android device...
info No filename is provided, pulling latest file
info File to be pulled: sampling-profiler-trace954625215651537236.cpuprofile
debug Internal commands run to pull the file:
debug adb shell run-as org.understood.community cat cache/sampling-profiler-trace954625215651537236.cpuprofile > /var/folders/mx/m72jxsrd6_g8bw4xql0rb0140000gn/T/sampling-profiler-trace954625215651537236.cpuprofile
debug Getting source maps from Metro packager server
(node:36867) Warning: Accessing non-existent property 'padLevels' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
debug Using source maps from Metro packager server
debug Successfully obtained the source map and stored it in /var/folders/mx/m72jxsrd6_g8bw4xql0rb0140000gn/T/index.map
error Invalid string length
RangeError: Invalid string length
    at JSON.stringify (<anonymous>)
    at downloadProfile (/Users/arahn/dev/understood/node_modules/@react-native-community/cli-hermes/build/profileHermes/downloadProfile.js:133:61)
    at async Object.profileHermes [as func] (/Users/arahn/dev/understood/node_modules/@react-native-community/cli-hermes/build/profileHermes/index.js:21:5)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions