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

Fix exceptions auto collector promise handling #618

Merged
merged 2 commits into from Apr 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions AutoCollection/Exceptions.ts
Expand Up @@ -46,7 +46,7 @@ class AutoCollectExceptions {
if (!this._exceptionListenerHandle) {
// For scenarios like Promise.reject(), an error won't be passed to the handle. Create a placeholder
// error for these scenarios.
var handle = (reThrow: boolean, name?: string, error: Error = new Error(AutoCollectExceptions._FALLBACK_ERROR_MESSAGE)) => {
var handle = (reThrow: boolean, name: string, error: Error = new Error(AutoCollectExceptions._FALLBACK_ERROR_MESSAGE)) => {
this._client.trackException({ exception: error });
this._client.flush({ isAppCrashing: true });
// only rethrow when we are the only listener
Expand All @@ -58,11 +58,11 @@ class AutoCollectExceptions {

if (AutoCollectExceptions._canUseUncaughtExceptionMonitor) {
// Node.js >= 13.7.0, use uncaughtExceptionMonitor. It handles both promises and exceptions
this._exceptionListenerHandle = handle.bind(this, false); // never rethrows
this._exceptionListenerHandle = handle.bind(this, false, undefined); // never rethrows
process.on(AutoCollectExceptions.UNCAUGHT_EXCEPTION_MONITOR_HANDLER_NAME, this._exceptionListenerHandle);
} else {
this._exceptionListenerHandle = handle.bind(this, true, AutoCollectExceptions.UNCAUGHT_EXCEPTION_HANDLER_NAME);
this._rejectionListenerHandle = handle.bind(this, false); // never rethrows
this._rejectionListenerHandle = handle.bind(this, false, undefined); // never rethrows
process.on(AutoCollectExceptions.UNCAUGHT_EXCEPTION_HANDLER_NAME, this._exceptionListenerHandle);
process.on(AutoCollectExceptions.UNHANDLED_REJECTION_HANDLER_NAME, this._rejectionListenerHandle);
}
Expand Down