Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZoneAwareError reads original stack despite setting __Zone_Error_ZoneJsInternalStackFrames_policy #43240

Open
vendi95 opened this issue Aug 24, 2021 · 1 comment
Assignees
Labels
area: zones P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Milestone

Comments

@vendi95
Copy link

vendi95 commented Aug 24, 2021

Which @angular/* package(s) are relevant/releated to the feature request?

No response

Description

Zone.js's ZoneAwareError always stores the original error's stack in the constructor by accessing error.stack no matter what the __Zone_Error_ZoneJsInternalStackFrames_policy is.

const originalStack = (error as any)['originalStack'] = error.stack;

This can lead to performance overhead in V8 when using custom stack traces because the prepareStackTrace method runs uneccesarily when constructing errors even if the error's stack will never be accessed.

In our project we use the source-map-support package that provides source map support for stack traces. This can be a costy operation first time (seconds), which we want to avoid when the error's stack is never accessed.

Proposed solution

If possible only access the original error's stack if it is necessary regarding the __Zone_Error_ZoneJsInternalStackFrames_policy.

Alternatives considered

.

@ngbot ngbot bot added this to the needsTriage milestone Aug 24, 2021
@JiaLiPassion JiaLiPassion self-assigned this Feb 20, 2022
arturovt added a commit to arturovt/angular that referenced this issue Mar 25, 2022
…policy is used

We don't have to read the `stack` property when the lazy stack frames policy is used.
The V8 triggers the stack trace serialization only when the `stack` property is read for
the first time within the `Accessors::ErrorStackGetter`. We want to avoid formatting the stack
trace when the lazy policy is used, and we don't need the stack until the `zoneAwareStack`
property is read.

PR Close angular#43240
arturovt added a commit to arturovt/angular that referenced this issue Mar 26, 2022
…policy is used

We don't have to read the `stack` property when the lazy stack frames policy is used.
The V8 triggers the stack trace serialization only when the `stack` property is read for
the first time within the `Accessors::ErrorStackGetter`. We want to avoid formatting the stack
trace when the lazy policy is used, and we don't need the stack until the `zoneAwareStack`
property is read.

PR Close angular#43240
arturovt added a commit to arturovt/angular that referenced this issue Mar 26, 2022
…policy is used

We don't have to read the `stack` property when the lazy stack frames policy is used.
The V8 triggers the stack trace serialization only when the `stack` property is read for
the first time within the `Accessors::ErrorStackGetter`. We want to avoid formatting the stack
trace when the lazy policy is used, and we don't need the stack until the `zoneAwareStack`
property is read.

PR Close angular#43240
arturovt added a commit to arturovt/angular that referenced this issue Mar 26, 2022
…policy is used

We don't have to read the `stack` property when the lazy stack frames policy is used.
The V8 triggers the stack trace serialization only when the `stack` property is read for
the first time within the `Accessors::ErrorStackGetter`. We want to avoid formatting the stack
trace when the lazy policy is used, and we don't need the stack until the `zoneAwareStack`
property is read.

PR Close angular#43240
arturovt added a commit to arturovt/angular that referenced this issue Mar 26, 2022
…policy is used

We don't have to read the `stack` property when the lazy stack frames policy is used.
The V8 triggers the stack trace serialization only when the `stack` property is read for
the first time within the `Accessors::ErrorStackGetter`. We want to avoid formatting the stack
trace when the lazy policy is used, and we don't need the stack until the `zoneAwareStack`
property is read.

PR Close angular#43240
arturovt added a commit to arturovt/angular that referenced this issue Mar 26, 2022
…policy is used

We don't have to read the `stack` property when the lazy stack frames policy is used.
The V8 triggers the stack trace serialization only when the `stack` property is read for
the first time within the `Accessors::ErrorStackGetter`. We want to avoid formatting the stack
trace when the lazy policy is used, and we don't need the stack until the `zoneAwareStack`
property is read.

PR Close angular#43240
arturovt added a commit to arturovt/angular that referenced this issue Jun 18, 2022
…policy is used

We don't have to read the `stack` property when the lazy stack frames policy is used.
The V8 triggers the stack trace serialization only when the `stack` property is read for
the first time within the `Accessors::ErrorStackGetter`. We want to avoid formatting the stack
trace when the lazy policy is used, and we don't need the stack until the `zoneAwareStack`
property is read.

PR Close angular#43240
@alxhub alxhub added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Nov 16, 2022
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Nov 16, 2022
arturovt added a commit to arturovt/angular that referenced this issue Jun 14, 2023
…policy is used

We don't have to read the `stack` property when the lazy stack frames policy is used.
The V8 triggers the stack trace serialization only when the `stack` property is read for
the first time within the `Accessors::ErrorStackGetter`. We want to avoid formatting the stack
trace when the lazy policy is used, and we don't need the stack until the `zoneAwareStack`
property is read.

PR Close angular#43240
@BraianS
Copy link

BraianS commented May 14, 2024

Good morning, any update on this matter? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: zones P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

No branches or pull requests

5 participants