mcollina / mcollina/node-errormailer

Do not call JSON.stringify() for circular structures

Open
#21 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29
Forks
3
PR merge metrics
No merged PRs in 30d

Description

This library is throwing a new error we haven't seen before:

TypeError: Converting circular structure to JSON
--> starting at object with constructor 'Socket'
| property '_httpMessage' -> object with constructor 'ClientRequest'
--- property 'socket' closes the circle
at JSON.stringify ()
at /var/www/videomail/production/source/node_modules/errormailer/index.js:107:57

It's this code line

locals.errorProperties[property] = JSON.stringify(errorToBeSent[property])

Let's fix this in a small PR by not calling JSON.stringify and consider another more robust npm package.

Maybe fast-safe-stringify or does anyone have a better idea?

Contributor guide

No contributing guide indexed for this repository

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 index.js line 107 and trace how errorProperties are prepared for transmission. Reproduce the circular Socket/ClientRequest case from the report, then verify that the chosen serialization behavior no longer raises the reported TypeError and preserves the error data.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
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.