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

192
Views
JS error stack is skipping caller of generator

While writing a logger, accessing the name of functions is ideal. Unfortunately this is quite tricky with strict mode. I have resorted to passing log messages as errors such as :

log(new Error("Foobar")

and then slicing up the error.stack to suit. I have come across an issue where the helpful function name is skipped in the stack output.

// helpfulName.ts
export const helpfulName = ()=> wrapper(networkCallWithSimilarName())

// wrapper.ts
export async function* wrapper(generator){
log(new Error("Foobar")
return generator // I actually for of ... yield here
}

// index.ts

(async ()=>{
for await (const response of helpfulName()) {
...
})()

with the expected log output something like

at wrapper wrapper.ts(line)
at wrapper.next (<anonymous>)
at helpfulName helpfulName.ts(line)
at index.ts(line)

but instead helpfulName is missing

at wrapper wrapper.ts(line)
at wrapper.next (<anonymous>)
at index.ts(line)

I have tried various iterations of ES6/ES5 functions and different methods of exporting and wrapping in more functions, but I have been unable to get any reference to the helpfulName.ts from an error in wrapper(). Is this possible? Why is it not in the stack trace?

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!