Stack not preserved in ajax.js
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
**mapbox-gl-js version**: 2.3.0, 2.8.1, etc
**browser**: Chrome etc
### Steps to Trigger Behavior
1. Somehow get an error with a puzzling message which hits https://github.com/mapbox/mapbox-gl-js/blob/main/src/util/ajax.js#L182 `if (!aborted) callback(new Error(err.message));`
2. Notice that the new error discards the stack which makes figuring out the error difficult
### Link to Demonstration
In my case the error showed up in tracking, and the repro steps are unclear. Hence, a stack trace would really help. The error message itself is `Error: Cannot read properties of undefined (reading 'send')` which is hard to debug, and it could be our bug, a mapbox bug, or anything else. So preserving the stack trace somehow or other would be useful to debug what is happening.
Obviously, stack preservation anywhere else errors are wrapped like this would be useful.
### Expected Behavior
The error has a convenient stack trace from the original error
### Actual Behavior
It does not
Contributor guide
Research direction
Start at src/util/ajax.js line 182, where the callback wraps the original error with a new Error. Reproduce the error path and verify that the resulting error retains the original stack trace, including the reported Cannot read properties of undefined message.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100