Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

368
Views
How to get a trace for where a JS error was thrown, not where it was created

I know that error.stack will give me an error stacktrace. That's fine when the error is created and immediately thrown, but I have some failing code where that's not happening: the error is created in one place, and then thrown somewhere later. I want to know where it's thrown, not where it's created.

Is there any way to find this information? This is a Node.js process (v14).

For context: I'm using some 3rd party code, which internally throws and caches an error, but then appears to handle it correctly. For some reason though, later on that same error instance comes out of the cache and gets thrown, crashing my application. I need to know who's throwing it.

A concrete example:

const err = new Error();

function f() {
  throw err;
}

f();

The stacktrace of err only shows the top level. How can I find out that err was thrown in f?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!