Skip to content

Commit 7fb1a73

Browse files
committed
fix(mcp): move webhooks init before createFeedbackStore to fix TDZ crash
Declare `categories` and `webhooks` before passing `webhooks` into `createFeedbackStore`, avoiding a TDZ ReferenceError at MCP startup. Also type-narrow the catch clause in `fireWebhook` (webhook.ts) instead of using `any`, as required under strict mode.
1 parent d96b665 commit 7fb1a73

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/mcp.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ export async function startMcpServer(): Promise<void> {
2222
const embed = await createEmbedder();
2323

2424
const sessionId = randomUUID();
25+
const categories = getCategories();
26+
const webhooks = getWebhooks();
2527
const store = createFeedbackStore({
2628
dbPath,
2729
sessionId,
@@ -31,9 +33,6 @@ export async function startMcpServer(): Promise<void> {
3133
});
3234

3335
await store.init();
34-
35-
const categories = getCategories();
36-
const webhooks = getWebhooks();
3736
const submitFeedbackSchema = createSubmitFeedbackSchema(categories);
3837
const listFeedbackSchema = createListFeedbackSchema(categories);
3938

src/webhook.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,9 @@ export async function fireWebhook(url: string, payload: Record<string, unknown>)
5050
`[suggestion-box] webhook POST to ${url} failed: HTTP ${response.status}`
5151
);
5252
}
53-
} catch (e: any) {
54-
console.error(`[suggestion-box] webhook POST to ${url} error: ${e.message}`);
53+
} catch (e) {
54+
const message = e instanceof Error ? e.message : String(e);
55+
console.error(`[suggestion-box] webhook POST to ${url} error: ${message}`);
5556
}
5657
}
5758

0 commit comments

Comments
 (0)