Fix the queue#95910
Draft
lukesandberg wants to merge 1 commit into
Draft
Conversation
Contributor
Tests PassedCommit: edc2ec4 |
Contributor
Stats from current PR✅ No significant changes detected📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URLCommit: edc2ec4 |
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
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.

What
Fixes duplicate compilation events in the dev/build trace — most visibly the
turbopack-persistenceTraceEvent, which showed up as two byte-identical spans in.next/trace.Why
CompilationEventQueuehad a register/replay race.sendandsubscribetouchedhistoryand thesubscribersmap under separate locks, in opposite orders. A subscriber caught between "registered" and "history replayed" could receive the same event both live and via replay. Because both paths forward the sameArc, the two spans were identical. Persistence events are the common victim: they fire unconditionally on every snapshot, including shortly after startup (idle-timeout snapshot), right in the subscribe window.How
Put
historyandsubscribersunder a single mutex and do each side's pair of operations in one critical section:send: push to history and snapshot the recipient channels, then deliver live after unlocking.subscribe: register the channel and snapshot history to replay, then replay after unlocking.An event is in the history snapshot iff it is not in the subscriber snapshot → exactly-once delivery per subscriber.
Notes
sendruns on its own spawned task) — this was already the case and nothing depends on it (trace spans self-order by embedded wall-clock timestamps). Documented onsend.