fix(ext/console): make timer and counter state per-instance to fix OTEL console wrapping#32719
Merged
bartlomieju merged 4 commits intomainfrom Mar 15, 2026
Merged
fix(ext/console): make timer and counter state per-instance to fix OTEL console wrapping#32719bartlomieju merged 4 commits intomainfrom
bartlomieju merged 4 commits intomainfrom
Conversation
…EL console wrapping When OTEL is enabled, `wrapConsole` calls both the OTEL Console and the original Console methods sequentially. Since `timerMap` and `countMap` were module-level singletons shared across all Console instances, the OTEL Console would modify timer/counter state before the original Console ran, causing spurious "Timer already exists" and "Timer does not exist" warnings. Move `timerMap` and `countMap` to private instance fields so each Console instance maintains independent state. Fixes #28818 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kajukitli
approved these changes
Mar 15, 2026
Contributor
kajukitli
left a comment
There was a problem hiding this comment.
Reviewed the changes with full repo context. No issues found.
crowlKats
approved these changes
Mar 15, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Console methods time/timeEnd/timeLog/count/countReset previously called this.info()/this.warn() internally. Since these are arrow functions with lexically captured `this`, they always invoked the original info/warn, bypassing the callConsole wrapper. This meant otelLog was never called for their output. Using this.#printFunc() directly ensures each Console instance's own print function is invoked. Also update console_time.out for log.iostream attribute from main. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
console.time/console.timeEnd/console.count/console.countResetproducing spurious warnings when OTEL is enabled (OTEL_DENO=true)timerMapandcountMapwere module-level singletons shared across allConsoleinstances. When OTEL wraps the console viawrapConsole, both the OTEL Console and the original Console methods are called sequentially, but they were sharing the same timer/counter state, so the second call would see already-modified state.timerMapandcountMapto private instance fields (#timerMap,#countMap) so eachConsoleinstance maintains independent state.Fixes #28818
Test plan
tests/specs/cli/otel_basic/console_timespec test that exercisesconsole.time/console.timeEnd/console.countwith OTEL enabledcargo test console)🤖 Generated with Claude Code