This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
fix(error): fix #674, handle error.stack readonly case #675
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
in phantomJS, the error.stack is readonly, so we need to catch such case and set the stack property directly to ZoneAwareError.
before 0.8.1, the case is OK because code here, https://github.com/angular/zone.js/blob/master/lib/zone.ts#L1955
and
https://github.com/angular/zone.js/blob/master/lib/zone.ts#L1992
before 0.8.1 , the stackTraceLimit is 15, so in PhantomJS, ZoneAwareError can't finish finding all run/runGuarded/runTask, so stackRewrite is false, and ZoneAwareError will not try to override NativeError.stack.
and in 0.8.1, the stackTraceLimit increased to 100 in detect phase, so ZoneAwareError can find all run/runGuarded/runTask, so stackRewrite is true.
In this PR, we just try/catch and write the zoneAware stack frames to ZoneAwareError directly