csnover / csnover/TraceKit

Unexpected error when computing Gecko stack traces

Open
#89 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.1k
Forks
162
PR merge metrics
No merged PRs in 30d

Description

By reviewing TraceKit code, I found an issue where the stack trace computation fails in certain condition. Keep in mind that I didn't observe an actual error matching this condition.

See [the code in question](https://github.com/csnover/TraceKit/blob/8f74ec6bcf7183e979c14e465c7abdd9fe4ce28e/tracekit.js#L819-L824):

```js
} else if (i === 0 && !parts[5] && !_isUndefined(ex.columnNumber)) {
// ...
stack[0].column = ex.columnNumber + 1;
}
```

The issue is, if `i === 0`, then the `stack` array is always empty, so accessing its first element returns `undefined`, and `stack[0].column` throws `TypeError: Cannot set properties of undefined`.

This piece of code is only used in Gecko if the first line doesn't contain any column number. You can see the tests failing if you remove the column number [here](https://github.com/csnover/TraceKit/blob/8f74ec6bcf7183e979c14e465c7abdd9fe4ce28e/spec/fixtures/captured-errors.js#L229) for example.

Now, because this has been an issue for a long time and nobody reported it, I'm not sure if this should be fixed or if this particular condition could be removed altogether. It seems that [Sentry chose the latter](https://github.com/getsentry/sentry-javascript/commit/b4765328077c1516f6d61951547d955638210820#diff-2a8e734b55c0a1c7ce99c23f6a6f1ae13ccb07ee89b6e75aba3bb13327c80166L158).

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.