Skip to content

Commit 69f1c85

Browse files
fix: contain embedding-bootstrap teardown rejection from plugin init
Co-authored-by: Alfonso <alfonso-magic-context@users.noreply.github.com>
1 parent 07e13e8 commit 69f1c85

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

packages/plugin/src/plugin/tool-registry.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import {
88
isDatabasePersisted,
99
openDatabase,
1010
} from "../features/magic-context/storage";
11+
import { getErrorMessage } from '../shared/error-message';
12+
import { log } from '../shared/logger';
1113
import type { Database } from "../shared/sqlite";
1214
import { createCtxExpandTools } from "../tools/ctx-expand";
1315
import { CTX_MEMORY_ACTIONS, createCtxMemoryTools } from "../tools/ctx-memory";
@@ -58,7 +60,12 @@ export function createToolRegistry(args: {
5860
return {};
5961
}
6062

61-
void ensureProjectRegisteredFromOpenCodeDirectory(ctx.directory, db);
63+
// Fire-and-forget: registration failure (including a database handle that
64+
// closed during process teardown) must never surface as an unhandled
65+
// rejection from plugin init. The next boot or embed path re-registers.
66+
void ensureProjectRegisteredFromOpenCodeDirectory(ctx.directory, db).catch((error) => {
67+
log(`[magic-context] embedding registration skipped: ${getErrorMessage(error)}`);
68+
});
6269

6370
// Tools resolve project per-call from `toolContext.directory` because
6471
// OpenCode's top-level `ctx.directory` reflects the launch dir, not the

0 commit comments

Comments
 (0)