Skip to content

Commit 0830913

Browse files
Coke1120claude
andcommitted
fix: log warn on initFailed in service.start() and fix stale test comment
When secret resolution fails, service.start() now logs a visible warn explaining why memory hooks are disabled, instead of silently skipping. Update stale comment in session-summary test: register() returns initPromise so awaiting it is meaningful, not just a sync guard. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a331761 commit 0830913

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,8 @@ const memoryLanceDBProPlugin = {
16531653
// embedder, retriever, and smartExtractor require async secret resolution.
16541654
// They are initialized in initPromise and must not be used before it resolves.
16551655
// Every hook that uses them awaits initPromise at its top.
1656-
// If initPromise rejects, initFailed is set and hooks silently skip.
1656+
// If initPromise rejects, initFailed is set; service.start() logs a warn so
1657+
// the user knows why memory features are unavailable.
16571658
let embedder!: ReturnType<typeof createEmbedder>;
16581659
let retriever!: ReturnType<typeof createRetriever>;
16591660
let smartExtractor: SmartExtractor | null = null;
@@ -3671,7 +3672,14 @@ const memoryLanceDBProPlugin = {
36713672
start: async () => {
36723673
// Wait for async secret resolution before running startup checks.
36733674
await initPromise;
3674-
if (initFailed) return;
3675+
if (initFailed) {
3676+
api.logger.warn(
3677+
"memory-lancedb-pro: secret resolution failed during startup — " +
3678+
"embedding, recall, and capture hooks are disabled. " +
3679+
"Check your embedding.apiKey / retrieval.rerankApiKey config.",
3680+
);
3681+
return;
3682+
}
36753683

36763684
// IMPORTANT: Do not block gateway startup on external network calls.
36773685
// If embedding/retrieval tests hang (bad network / slow provider), the gateway

test/session-summary-before-reset.test.mjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ describe("systemSessionMemory before_reset", () => {
102102
const dbPath = path.join(workDir, "db");
103103
const api = createApiHarness({ dbPath, embeddingBaseURL });
104104

105-
memoryLanceDBProPlugin.register(api);
106-
// register() is sync; before_reset is available immediately.
105+
await memoryLanceDBProPlugin.register(api);
106+
// register() returns initPromise; awaiting it ensures secrets are resolved
107+
// and hooks (including before_reset) are fully initialized.
107108
assert.equal(typeof api.hooks.before_reset, "function");
108109
assert.equal(api.hooks["command:new"], undefined);
109110

0 commit comments

Comments
 (0)