-
Notifications
You must be signed in to change notification settings - Fork 63
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
feat(js): reload unhandledRejection and uncaughtException plugins on configure #1184
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,6 @@ export default class UnhandledRejectionMonitor { | |
|
||
makeListener() { | ||
const honeybadgerUnhandledRejectionListener = (reason: unknown, _promise: Promise<unknown>) => { | ||
if (!this.__client || !this.__client.config.enableUnhandledRejection) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant now that the listener is removed in this case. I'd only included |
||
if (!this.hasOtherUnhandledRejectionListeners() && !this.__isReporting) { | ||
fatallyLogAndExit(reason as Error) | ||
} | ||
return | ||
} | ||
|
||
this.__isReporting = true; | ||
this.__client.notify(reason as Types.Noticeable, { component: 'unhandledRejection' }, { | ||
afterNotify: () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -299,4 +299,29 @@ describe('server client', function () { | |
expect(request.isDone()).toBe(true) | ||
}) | ||
}) | ||
|
||
describe('__plugins', function () { | ||
it('exported singleton includes plugins', function () { | ||
Singleton.configure({ apiKey: 'foo' }) | ||
expect(Singleton.config.__plugins.length).toBe(2) | ||
}) | ||
|
||
it('clients produced via factory don\'t include plugins', function () { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are debating whether this is what we want in #1181, but I figured I'd document the current behavior. |
||
client.configure({ apiKey: 'foo' }) | ||
expect(client.config.__plugins.length).toBe(0) | ||
}) | ||
|
||
// Integration test with the plugins themselves | ||
it('uncaughtException and unhandledRejection plugins reload on configure', function () { | ||
function getListenerCount(type) { | ||
return process.listeners(type).length | ||
} | ||
Singleton.configure({ apiKey: 'foo' }) | ||
expect(getListenerCount('uncaughtException')).toBe(1) | ||
expect(getListenerCount('unhandledRejection')).toBe(1) | ||
Singleton.configure({ enableUncaught: false, enableUnhandledRejection: false }) | ||
expect(getListenerCount('uncaughtException')).toBe(0) | ||
expect(getListenerCount('unhandledRejection')).toBe(0) | ||
}) | ||
}) | ||
}) |
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.
Redundant now that the listener is removed in this case