netlify / netlify/cli

`netlify dev` crashes if function throws custom error with no `stackTrace` property

Open
#6,215 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
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
  1. git clone git@github.com:cubeghost/glowing-rotary-phone.git
  2. netlify dev
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.