Skip to content

Commit 9f8bed9

Browse files
committed
fix(core): Wrap beforeSendLog in consoleSandbox
1 parent 101b4f2 commit 9f8bed9

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/core/src/logs/exports.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { Scope, ScopeData } from '../scope';
66
import type { Log, SerializedLog, SerializedLogAttributeValue } from '../types-hoist/log';
77
import { mergeScopeData } from '../utils/applyScopeDataToEvent';
88
import { isParameterizedString } from '../utils/is';
9-
import { debug } from '../utils/logger';
9+
import { consoleSandbox, debug } from '../utils/logger';
1010
import { _getSpanForScope } from '../utils/spanOnScope';
1111
import { timestampInSeconds } from '../utils/time';
1212
import { GLOBAL_OBJ } from '../utils/worldwide';
@@ -169,7 +169,8 @@ export function _INTERNAL_captureLog(
169169

170170
client.emit('beforeCaptureLog', processedLog);
171171

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

0 commit comments

Comments
 (0)