(...args: any[])
| 78 | let isExecuting = false; |
| 79 | |
| 80 | const wrapper = function (...args: any[]): void { |
| 81 | if (isExecuting) { |
| 82 | // Re-entrant call: a third party captured `wrapper` via the getter and calls it from inside their replacement. We must |
| 83 | // use `nativeMethod` (not `delegate`) to break the cycle, and we intentionally skip `triggerHandlers` to avoid duplicate |
| 84 | // breadcrumbs. The outer invocation already triggered the handlers for this console call. |
| 85 | nativeMethod.apply(consoleObj, args); |
| 86 | return; |
| 87 | } |
| 88 | isExecuting = true; |
| 89 | try { |
| 90 | triggerHandlers('console', { args, level } as HandlerDataConsole); |
| 91 | delegate.apply(consoleObj, args); |
| 92 | } finally { |
| 93 | isExecuting = false; |
| 94 | } |
| 95 | }; |
| 96 | markFunctionWrapped(wrapper as unknown as WrappedFunction, nativeMethod as unknown as WrappedFunction); |
| 97 | |
| 98 | // consoleSandbox reads originalConsoleMethods[level] to temporarily bypass instrumentation. We replace it with a distinct reference (.bind creates a |
no test coverage detected