Skip to content

fix(core): Wrap beforeSendLog in consoleSandbox #16968

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 1 commit into from
Jul 14, 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
5 changes: 3 additions & 2 deletions packages/core/src/logs/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { Scope, ScopeData } from '../scope';
import type { Log, SerializedLog, SerializedLogAttributeValue } from '../types-hoist/log';
import { mergeScopeData } from '../utils/applyScopeDataToEvent';
import { isParameterizedString } from '../utils/is';
import { debug } from '../utils/logger';
import { consoleSandbox, debug } from '../utils/logger';
import { _getSpanForScope } from '../utils/spanOnScope';
import { timestampInSeconds } from '../utils/time';
import { GLOBAL_OBJ } from '../utils/worldwide';
Expand Down Expand Up @@ -169,7 +169,8 @@ export function _INTERNAL_captureLog(

client.emit('beforeCaptureLog', processedLog);

const log = beforeSendLog ? beforeSendLog(processedLog) : processedLog;
// We need to wrap this in `consoleSandbox` to avoid recursive calls to `beforeSendLog`
const log = beforeSendLog ? consoleSandbox(() => beforeSendLog(processedLog)) : processedLog;
if (!log) {
client.recordDroppedEvent('before_send', 'log_item', 1);
DEBUG_BUILD && debug.warn('beforeSendLog returned null, log will not be captured.');
Expand Down
Loading