Skip to content

metro-symbolicate: Don't throw on stack frames with no source position - #1891

Open
robhogan wants to merge 1 commit into
mainfrom
pr1891
Open

metro-symbolicate: Don't throw on stack frames with no source position#1891
robhogan wants to merge 1 commit into
mainfrom
pr1891

Conversation

@robhogan

@robhogan robhogan commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

metro-symbolicate aborts with TypeError: Line must be greater than or equal to 1, got 0 and emits nothing at all if any frame in the input has line 0. One such frame discards the whole trace, which is why folks in #966 are hand-editing their stack traces first.

Line 0 isn't necessarily malformed input - it's how some crash reporters, Crashlytics for example, represent a frame with no JS source position once every frame has been normalised to file:line:column, rendering [native code] as [native code]:0:0. We already accept the un-normalised form: symbolicate()'s regex has an explicit [native code] alternative and reports those frames as null:null:null.

This makes the normalised form behave the same. getOriginalPositionDetailsFor returns an unresolved frame instead of passing a position source-map rejects, and the regex consumes a trailing :0:0 after [native code] so the frame matches once rather than twice.

Fixes: #966
Fixes: #1021

Changelog:

 - **[Fix]**: `metro-symbolicate` no longer fails on stack frames with no source position, such as `[native code]:0:0` in crash reporter output

Test plan

yarn jest packages/metro-symbolicate
yarn flow check

New snapshot test over a crash-reporter-formatted trace containing [native code]:0:0 frames, which fails on main with the TypeError.

## Summary

`metro-symbolicate` aborts with `TypeError: Line must be greater than or equal to 1, got 0` and emits nothing at all if any frame in the input has line 0. One such frame discards the whole trace, which is why folks in #966 are hand-editing their stack traces first.

Line 0 isn't necessarily malformed input - it's how some crash reporters, Crashlytics for example, represent a frame with no JS source position once every frame has been normalised to `file:line:column`, rendering `[native code]` as `[native code]:0:0`. We already accept the un-normalised form: `symbolicate()`'s regex has an explicit `[native code]` alternative and reports those frames as `null:null:null`.

This makes the normalised form behave the same. `getOriginalPositionDetailsFor` returns an unresolved frame instead of passing a position `source-map` rejects, and the regex consumes a trailing `:0:0` after `[native code]` so the frame matches once rather than twice.

Fixes: #966

Changelog:
```
 - **[Fix]**: `metro-symbolicate` no longer fails on stack frames with no source position, such as `[native code]:0:0` in crash reporter output
```

## Test plan

```
yarn jest packages/metro-symbolicate
yarn flow check
```

New snapshot test over a crash-reporter-formatted trace containing `[native code]:0:0` frames, which fails on `main` with the `TypeError`.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 31, 2026
@facebook-github-tools facebook-github-tools Bot added the Shared with Meta Applied via automation to indicate that an Issue or Pull Request has been shared with the team. label Aug 31, 2026
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

1 participant