-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[BUGFIX release] ensure “pause on exception” pauses in the right place #15599
Conversation
dc120d4
to
1fc7137
Compare
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.
I think we also need a test for this. Something like:
import {
onErrorTarget,
getDispatchOverride,
setDispatchOverride,
getOnerror,
setOnerror
} from '../error_handler';
const DISPATCH_OVERRIDE = getDispatchOverride();
const ONERROR = getOnerror();
module('error_handler', {
afterEach() {
setOnerror(ONERROR);
setDispatchOverride(DISPATCH_OVERRIDE);
}
});
test('by default there is no onerror', function(assert) {
assert.equal(onErrorTarget.onerror, undefined);
});
test('when dispatch override is registered', function(assert) {
assert.expect(2);
let override = () => assert.ok(true, 'dispatch called');
setDispatchOverride(overide);
assert.equal(onErrorTarget.onerror, override);
});
test('when onerror is registered', function(assert) {
assert.expect(2);
let override = () => assert.ok(true, 'onerror called');
setOnerror(overide);
assert.equal(onErrorTarget.onerror, override);
});
@@ -13,6 +13,12 @@ let getStack = error => { | |||
return stack; | |||
}; | |||
|
|||
export const onErrorTarget = { | |||
get onerror() { | |||
return dispatchError || getOnerror(); |
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.
Maybe I'm missing something, but I don't see how this works since dispatchError
is always defined just below here?
I would think you want this to actually be:
export const onErrorTarget = {
get onerror() {
return getDispatchOverride() || getOnerror();
}
}
1fc7137
to
2a28a8f
Compare
yup, test looks good. Adding it |
@stefanpenner - We should consider backporting this to 2.12 LTS. Thoughts? |
It is quite common (like in ember-data’s tests) to not have a global onError handler in tests. But because of the previous state of code, we would still end up paused in the default dispatchError rather then where the actual error was thrown. This addresses the issue, but ensuring onErrorTarget.onerror returns undefined if no onError has been set
2a28a8f
to
e16ffc7
Compare
There appears to be a BB issue preventing this from working correctly. |
I think -> BackburnerJS/backburner.js#262 fixes the BB issue |
ya that BB fix address this (linked locally) |
oh GH you so silly... #15600 |
It is quite common (like in ember-data’s tests) to not have a global onError handler in tests.
But because of the previous state of code, we would still end up paused in the default dispatchError rather then where the actual error was thrown.
This addresses the issue, but ensuring onErrorTarget.onerror returns undefined if no onError has been set
before:
After: