fix(core): flush plugin reload generations - #41309
Merged
Merged
Conversation
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
Makes
PluginSupervisor.flushwait for the current plugin activation generation, including hot reloads after startup, and repairs the regression test so it cannot deadlock.Before / After
Before:
5b3997294757758c8d0e4fc13196a4c3211286faintroducedflushas an await of one startupDeferred. Once startup completed, every laterflushreturned immediately even if a hot reload was active. Its "keeps flush open while later hot reload runs" test synchronously awaited that flush before releasing the deliberately blocked activation. Depending on update observation timing, the test either passed for the wrong reason (flush returned too early) or deadlocked until Bun's 5-second timeout.After: accepting work replaces a completed generation barrier, activation completes the current barrier only after all observed work settles, and each
flushresolves the barrier current at execution time. The test forks flush, verifies it remains pending, releases activation, and joins it.How
packages/core/src/plugin/supervisor.tsrotates the readinessDeferredwhen post-ready work is observed.flushusesEffect.suspendso callers await the current generation rather than the startup generation captured while constructing the service.packages/core/test/location-layer.test.tsexercises the intended ordering without blocking its own release step.This is a fix rather than a revert because the plugin readiness behavior introduced by the culprit commit is required; only its one-shot generation tracking was incomplete.
Scope
This PR only addresses plugin flush generation tracking. The independent recorded OpenAI cassette mismatch and TUI CI races are handled in separate PRs.
Testing
cd packages/core && bun typecheckpasses.cd packages/core && bun run test test/location-layer.test.tspasses three consecutive runs: 18 tests each, 0 failures.cd packages/core && bun run testpasses all location-layer tests. The full suite still reports the independent recorded session-runner timeout and the documented local-onlyPluginSupervisor config > logs invalid packages and continues loadingfailure caused by global user plugins.