Skip to content

fix(core): Remove side-effect from tracing/errors.ts #16888

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

Merged
merged 5 commits into from
Jul 11, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions packages/core/src/tracing/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,24 @@ export function registerSpanErrorInstrumentation(): void {
return;
}

/**
* If an error or unhandled promise occurs, we mark the active root span as failed
*/
function errorCallback(): void {
const activeSpan = getActiveSpan();
const rootSpan = activeSpan && getRootSpan(activeSpan);
if (rootSpan) {
const message = 'internal_error';
DEBUG_BUILD && debug.log(`[Tracing] Root span: ${message} -> Global error occurred`);
rootSpan.setStatus({ code: SPAN_STATUS_ERROR, message });
}
}

// The function name will be lost when bundling but we need to be able to identify this listener later to maintain the
// node.js default exit behaviour
errorCallback.tag = 'sentry_tracingErrorCallback';

errorsInstrumented = true;
addGlobalErrorInstrumentationHandler(errorCallback);
addGlobalUnhandledRejectionInstrumentationHandler(errorCallback);
}

/**
* If an error or unhandled promise occurs, we mark the active root span as failed
*/
function errorCallback(): void {
const activeSpan = getActiveSpan();
const rootSpan = activeSpan && getRootSpan(activeSpan);
if (rootSpan) {
const message = 'internal_error';
DEBUG_BUILD && debug.log(`[Tracing] Root span: ${message} -> Global error occurred`);
rootSpan.setStatus({ code: SPAN_STATUS_ERROR, message });
}
}

// The function name will be lost when bundling but we need to be able to identify this listener later to maintain the
// node.js default exit behaviour
errorCallback.tag = 'sentry_tracingErrorCallback';
Loading