You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Getting a stack trace can be an expensive operation, and both Firefox and Chrome/V8 (haven't checked IE/Edge) optimize it by formatting the unstructured stack trace of an error on demand, the first time the stack property is accessed (https://github.com/v8/v8/wiki/Stack-Trace-API#customizing-stack-traces).
When building instrumentation tooling, I use this to minimize the overhead of capturing the stack trace using new Error() and then evaluate its stack property if and when needed. Unfortunately, ZoneAwareError does the trace evaluation and formatting in its constructor, so it ends up a lot slower, both from invoking the native error's formatting, and Zone.js's own overhead. I have also noticed it resulting in increased memory pressure, leading to more frequent GC pauses:
(The first half is running new NativeError(), the second is running new Error().)
Benchmark demonstrating the issue - https://jsperf.com/zoneawareerror.
Note that this runs the benchmark with an unrealistically shallow call stack. The real life impact in a complex application is likely to be more pronounced.
Is it possible to make it evaluate and rewrite the stack on demand?