Repository navigation
Conversation
There was a problem hiding this comment.
The fix looks right. I ran the new regression test against the base: it fails there (plugin.list() reports reloading/trailing as active while their tools are missing from tool.list()) and passes with this change. plugin.test.ts (24) and the related plugin, supervisor and module tests (36) all pass. I couldn't run the package typecheck script here (bun check isn't available), and tsc only showed build errors that are also on the base.
Reading list() live keeps stop-before-start ordering intact, and Plugin.Event.Updated still fires only after the reload. The state schema has only active/failed, so leaving restarting plugins out of the list is a reasonable way to keep both views consistent.
Public API: no schema, route or type changes. The only visible difference is that plugin.list (HTTP and ctx.plugin.list()) now leaves restarting plugins out while a reload is in progress, instead of showing them as active. Clients that refetch on plugin.updated are unaffected.
No blocking concerns.
Related: #59993
b2a5e8e to
60bd175
Compare
There was a problem hiding this comment.
The new push is a rebase onto a newer dev. The PR's own diff is the same as before, and my earlier review left nothing open. I checked again on the new base: the regression test fails there and passes with this change. The related plugin tests pass (60/60). The public API is unchanged since my last review. No new concerns.
Issue for this PR
Closes #64464
Type of change
What does this PR do?
During an in-place plugin reload,
Plugin.activatedeletes the outgoing suffix slots fromactiveand closes their scopes (removing their tools and other scoped registrations) before loading replacements, preserving the stop-before-start lifecycle contract. Previously,Plugin.listreturned a cachedinventoryarray that was only rebuilt at the end of the reload, so callers readingplugin.list()mid-reload still saw the torn-down plugins asactivewhiletool.list()no longer contained their tools.This removes the cached
inventoryinpackages/core/src/plugin.tsand computessnapshot()live inPlugin.list()(passingsnapshot()directly topublish()). Becauseactive.delete(id)runs beforeScope.close(...)andactive.set(...)runs only after replacement setup finishes,plugin.list()stays consistent with live registrations throughout reload without changing stop-before-start ordering.How did you verify your code works?
packages/core/test/plugin.test.tsthat pauses mid-reload with aDeferredand assertsplugin.list()does not report the reloading plugin (or restarted trailing plugins) asactivewhile their tools are absent fromtool.list(). Verified it failed before the fix and passes after.bun run script/test.ts test/plugin.test.ts(24 pass, plus--rerun-each 10 --randomizeon the new test), related plugin tests (plugin-failure.test.ts,plugin/supervisor.test.ts,plugin/supervisor-reload.test.ts,plugin/module.test.ts: 36 pass),bun typecheckinpackages/core,bunx oxlint, andbunx prettier --check.Screenshots / recordings
N/A — core/server fix.
Checklist
Added by the opencode bot (AI-generated).
Related: #59993