`netlify dev` crashes if function throws custom error with no `stackTrace` property
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.9k
- Forks
- 474
- Avg merge
- 23h 30m
- Merged PRs (30d)
- 53
Description
Describe the bug
If a function throws a custom error (not an instanceof Error) that doesn't have a stackTrace property, netlify dev crashes because it can't format the stack trace
Example of a library with a custom error class that causes this in the wild: https://github.com/Airtable/airtable.js/blob/master/src/airtable_error.ts
Steps to reproduce
git clone git@github.com:cubeghost/glowing-rotary-phone.gitnetlify dev- visit http://localhost:8888/.netlify/functions/hello
Configuration
No response
Environment
System:
OS: macOS 13.6.1
CPU: (10) arm64 Apple M1 Pro
Memory: 82.97 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.18.2 - ~/.nvm/versions/node/v18.18.2/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.8.1 - ~/.nvm/versions/node/v18.18.2/bin/npm
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at src/lib/functions/synchronous.ts line 118, where the issue reports that the stack trace is formatted, then reproduce the crash with the linked glowing-rotary-phone project using netlify dev. Done means a custom thrown error without a stackTrace property no longer crashes netlify dev when the function endpoint is visited.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100