The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu
Go agent-ai-cliagent-harnessesagent-securitybrowser-extensionciclaude-codecloudcodexcursordetection-engineeringjevknowledge-basememorymobile-device-managementobservabilitysecuritysecurity-information-and-event-managementsecurity-toolstelemetrytraces
fix(opencode): finish hook cleanup after synchronous disposal errors (#825)
Rudy Mizrahi Celekli980e235ee2bb
diff --git a/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts b/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.tsindex 1e2715f4..105e3e39 100644--- a/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts+++ b/cli/beacon/internal/endpoint/hooks/assets/opencode/beacon.ts@@ -610,7 +610,7 @@ export default {return async () => {controller.abort()await consuming- await Promise.all(registrations.map((item) => Promise.resolve(item.dispose?.()).catch(() => undefined)))+ await Promise.all(registrations.map((item) => Promise.resolve().then(() => item.dispose?.()).catch(() => undefined)))}},}diff --git a/plugins/opencode-beacon/src/beacon.test.ts b/plugins/opencode-beacon/src/beacon.test.tsindex 9832ce8c..8d8db8b3 100644--- a/plugins/opencode-beacon/src/beacon.test.ts+++ b/plugins/opencode-beacon/src/beacon.test.ts@@ -13,6 +13,26 @@ afterEach(() => {delete (globalThis as any)[senderKey]})+test.each(["synchronous", "asynchronous"])("disposes every V2 hook after a %s cleanup failure", async (kind) => {+ const disposed: string[] = []+ const register = async (name: string) => ({+ dispose() {+ disposed.push(name)+ if (name === "prompt") {+ if (kind === "synchronous") throw new Error("synthetic disposal failure")+ return Promise.reject(new Error("synthetic disposal failure"))+ }+ },+ })+ const dispose = await BeaconDefinition.setup({+ session: { hook: register },+ tool: { hook: register },+ event: { async *subscribe() {} },+ } as any)+ await expect(dispose()).resolves.toBeUndefined()+ expect(disposed).toEqual(["prompt", "execute.before", "execute.after"])+})+async function plugin() {return BeaconEndpointPlugin({project: { id: "project-1" },diff --git a/plugins/opencode-beacon/src/beacon.ts b/plugins/opencode-beacon/src/beacon.tsindex 1e2715f4..105e3e39 100644--- a/plugins/opencode-beacon/src/beacon.ts+++ b/plugins/opencode-beacon/src/beacon.ts@@ -610,7 +610,7 @@ export default {return async () => {controller.abort()await consuming- await Promise.all(registrations.map((item) => Promise.resolve(item.dispose?.()).catch(() => undefined)))+ await Promise.all(registrations.map((item) => Promise.resolve().then(() => item.dispose?.()).catch(() => undefined)))}},}