r/webdev • • 19d ago

Article Your JS Error Is Lying to You

https://blog.gaborkoos.com/posts/2026-11-12-Your-JS-Error-Is-Lying-to-You/

Started with a log line that said "err":{} for an error that definitely had a message and a cause. Followed that up to see what each step between new Error() and the log record actually keeps.

Covers stack traces, cause chains, AggregateError and SuppressedError. It runs the same probe script in Node.js, Deno, Bun, Chrome, Firefox and WebKit. It also sends errors across Web Workers, worker_threads, child_process IPC and HTTP, and logs them with Pino and Winston.

11 Upvotes

7 comments sorted by

2

u/Sensitive-Bridge-550 19d ago

Nothing like an empty error object to confirm that something happened somewhere

1

u/TheoMa_Builds 19d ago

the cause part is sneaky imo. console.log in node prints the [cause] fine so it looks ok locally, and then whatever serializes it for the prod logs does its own thing

1

u/marcin_dev 17d ago

The serialization advice already in the thread is right, but I'd also cap how deep the cause chain can go and stop if a cause points back at itself. Before the record leaves your process, strip tokens and URLs that contain credentials out of the message and the stack, or you'll end up sending secrets to the log vendor.

1

u/boneskull 19d ago

JavaScript does not lie, nor does it tell the truth. It behaves precisely as it means to