-
Notifications
You must be signed in to change notification settings - Fork 407
feat(longStackTraceSpec): handled promise rejection can also render longstacktrace #631
Conversation
9859dc9
to
176daef
Compare
lib/zone-spec/long-stack-trace.ts
Outdated
@@ -6,6 +6,8 @@ | |||
* found in the LICENSE file at https://angular.io/license | |||
*/ | |||
|
|||
import {zoneSymbol} from '../common/utils'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't do imports like that, because it would pull in the whole utils file. This file is meant to be stand alone and so no external imports are allowed.
Just use Zone.__symbol__
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right, I will modify it.
By the way, I just found the same problem exists in my previous PR, for web-apis-mediaquery patch, and web-apis-notification patch, those patches are also be separated, and import function from utils. I will also modify those files to make sure the standalone files not import from utils.
176daef
to
36083a7
Compare
@mhevery , I have modified it , please review. |
36083a7
to
b067c1f
Compare
}); | ||
promise.catch(function(error) { | ||
expect(longStackTraceZoneSpec.getLongStackTrace(error).split('Elapsed: ').length) | ||
.toBe(4); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly is this asserting? Could we make a test which is more explicit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here the asserting means with the longStackTraceZoneSpec.getLongStackTrace method, error which was catch in handing promise rejection can have long stack trace, so here I just assert the stack trace contains Elapsed:
string.
@@ -91,6 +92,25 @@ describe('longStackTraceZone', function() { | |||
}, 0); | |||
}); | |||
}); | |||
|
|||
it('should produce long stack traces when has handled error in promise', function(done) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...when handling errors in promises
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modified
b067c1f
to
01aa37f
Compare
@mhevery , I have updated the comment, please review whether it is ok. thank you. |
b55b4ad
to
f3b8885
Compare
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
1 similar comment
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
CLAs look good, thanks! |
CLAs look good, thanks! |
In this case, the error p.catch got is not a longStackTrace, because it is a handled promise rejection so it will not call longStackTraceSpec's onHandleError callback.
in this PR, I add a helper method in LongStackTraceZoneSpec, so if user want to render longStackTrace in promise.then/catch, user can call the method.
Here, user should call longStackTraceZoneSpec.getLongStackTrace(error) themselves, error.stack
is still the original stack. the reason that not set stack automatically here is because I don't want to break the logic of "handled promise rejection".