fix: use try_init instead of init for tracing subscriber to avoid panic#8698
Closed
cal-gooo wants to merge 1 commit intorolldown:mainfrom
Closed
fix: use try_init instead of init for tracing subscriber to avoid panic#8698cal-gooo wants to merge 1 commit intorolldown:mainfrom
cal-gooo wants to merge 1 commit intorolldown:mainfrom
Conversation
When running concurrent builds, `set_global_default()` (called by `.init()`) panics if a global subscriber has already been set. Replace `.init()` with `.try_init()` so the second call gracefully returns an error instead of panicking. Closes rolldown#8656 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merging this PR will not alter performance
Comparing Footnotes
|
Member
|
this is not a good fix for this race condition. |
2 tasks
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
.init()with.try_init()for tracing subscriber initialization inrolldown_tracingandrolldown_devtools.init()callsset_global_default()which panics if a global subscriber is already set;.try_init()returns aResultinsteadbuild()calls viaPromise.all) where the second initialization would panicCloses #8656
Test plan
cargo check -p rolldown_tracing -p rolldown_devtoolspassesSetGlobalDefaultError🤖 Generated with Claude Code