WebWeWant / webwewant.fyi

If you build websites, you inevitably run into problems. Maybe there’s no way to achieve an aspect of your design using CSS. Or maybe there’s a device feature you really wish you could tap into using JavaScript. Or perhaps the in-browser DevTools don’t give you a key insight you need to do your job. We want to hear about it!
https://webwewant.fyi
MIT License
76 stars 23 forks source link

I want JavaScript error stack traces to be more helpful #544

Open WebWeWantBot opened 2 years ago

WebWeWantBot commented 2 years ago

title: I want JavaScript error stack traces to be more helpful date: 2022-05-06T08:31:27.915Z submitter: Patrick Brosset number: 6274dcdfbd1cff009452d7c7 tags: [ ] discussion: https://github.com/WebWeWant/webwewant.fyi/discussions/ status: [ discussing || in-progress || complete ] related:

In particular, I would love it if they contained a serialized version of the arguments and return values for each function call on the stack. On top of this, I believe that capturing previous stacks would also help developers narrow in on a bug's root cause much faster.

Tracing debuggers record all of a program execution for some time. I would love it if JavaScript engines did a bit of tracing too. There are obvious performance implications here, so this should likely only happen in a "dev" mode. But what engines report now is too little information. The source of a bug may not be contained within the list of functions that are reported in the error call stack. In fact, it very often isn't. What is in the call stack is the location where the final problem occurred, but the root cause for it.

Having access, once the error was thrown, to a number of previous traces, complete with function names, arguments, return values, has the potential of making it so much faster to identify the root cause of a bug.

The current process is frustrating and time consuming. It relies on semi-randomly setting breakpoints or console.log messages throughout your code.

I wrote a longer form about this idea on my blog: https://patrickbrosset.com/articles/2022-05-05-better-stacktraces-for-faster-debugging/


If posted, this will appear at https://webwewant.fyi/wants/6274dcdfbd1cff009452d7c7/