GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||
GeezerVison is showing github.com — fix(core): keep the generation swap when a plugin cleanup throws by Veld101 · Pull Request #57096 · anomalyco/opencode Conversation
|
|
The following comment was made by an LLM, it may be inaccurate: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The fix is sound. On the base, the reproduction from #57089 fails: when a plugin's cleanup throws, activate() fails and the builtin's command is gone afterwards. With this PR the swap succeeds and the builtin's new revision is registered. Your new test fails without the fix and passes with it. The plugin test suites (422 tests) and the packages/core typecheck pass.
The new handling copies what the file already does when cleaning up disabled plugins (catchCause + log), so it fits. Interruption isn't a concern here, because Scope.close runs finalizers in a way that can't be interrupted.
Public API: unchanged.
No blocking concerns.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
One edge case in the new catch: Effect.catchCause also turns an interruption from a cleanup finalizer into successful activation. Could this use the existing Effect.catchCauseIf((cause) => !Cause.hasInterrupts(cause), ...) pattern used later in this file, and add an interruption regression?
I checked with the real PluginTestLayer and Bun 1.4.2 using this test body:
Effect.gen(function* () { const plugins = yield* Plugin.Service yield* plugins.activate([ { id: "interrupted", revision: "1", effect: () => Effect.addFinalizer(() => Effect.interrupt) }, ]) const activation = yield* plugins.activate([]).pipe(Effect.forkChild({ startImmediately: true })) const exit = yield* Fiber.await(activation) expect(Exit.isFailure(exit)).toBe(true) if (Exit.isFailure(exit)) expect(Cause.hasInterrupts(exit.cause)).toBe(true) })
From packages/core: bun run script/test.ts test/plugin-failure.test.ts --test-name-pattern "preserves interruption during plugin cleanup".
The check passes on the pre-fix source, fails with the exact plugin.ts blob from this PR's 10e87b9 (Expected: true; Received: false), and passes with catchCauseIf. This is a local focused check, not a full-suite result. AI assistance was used for the test and analysis.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
`Plugin.activate` closes the previous generation before loading the new one, and
the close loop had no per-plugin isolation. A plugin whose finalizer throws
aborted the whole activation: the old builtins had already been closed, the new
generation never loaded, and their transforms were never re-registered. Builtin
state then fell back to defaults, so a user plugin's broken cleanup silently
re-enabled `compaction.auto` despite `compaction: { auto: false }` (anomalyco#57089).
Each old slot now closes independently, logging `failed to close plugin` with the
id and cause. One plugin's teardown failure is reported instead of aborting the
swap, so the new generation still loads and builtins keep their registrations.
Adds a case with a finalizer that throws only for the revision being replaced, so
the surviving generation tears down normally and the assertion covers the swap
alone. It fails without the change: the error escapes `Plugin.activate` and the
builtin command is gone.
10e87b9 to
536dc02
Compare
|
Good catch — adopted. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
A throwing plugin cleanup during reload aborts the generation swap and silently drops builtin registrations
There was an error while loading. Please reload this page.