diff --git a/src/modules/internal.ts b/src/modules/internal.ts index bde26ee..b5fd63a 100644 --- a/src/modules/internal.ts +++ b/src/modules/internal.ts @@ -8,7 +8,6 @@ import { import { PublishEventRequestEventTypeEnum } from "mcpcat-api"; import { publishEvent } from "./eventQueue.js"; import { writeToLog } from "./logging.js"; -import { captureException } from "./exceptions.js"; /** * Simple LRU cache for session identities. @@ -196,14 +195,7 @@ export async function handleIdentify( } } catch (error) { writeToLog( - `Warning: Supplied identify function threw an error while identifying session ${sessionId} - ${error}`, + `Error: User supplied identify function threw an error while identifying session ${sessionId} - ${error}`, ); - identifyEvent.duration = - (identifyEvent.timestamp && - new Date().getTime() - identifyEvent.timestamp.getTime()) || - undefined; - identifyEvent.isError = true; - identifyEvent.error = captureException(error); - publishEvent(server, identifyEvent); } } diff --git a/src/tests/error-capture.test.ts b/src/tests/error-capture.test.ts index 079dc26..b01e14e 100644 --- a/src/tests/error-capture.test.ts +++ b/src/tests/error-capture.test.ts @@ -331,7 +331,7 @@ describe("Error Capture Integration Tests", () => { } }); - it("should capture identify errors with stack traces", async () => { + it("should NOT publish identify events when identify function throws", async () => { const { server, client, cleanup } = await setupTestServerAndClient(); try { @@ -361,21 +361,19 @@ describe("Error Capture Integration Tests", () => { // Wait for events await new Promise((resolve) => setTimeout(resolve, 100)); - // Find identify error event + // Verify NO identify event was published (errors in identify should only be logged, not published) const events = eventCapture.getEvents(); const identifyEvent = events.find( - (e) => - e.eventType === PublishEventRequestEventTypeEnum.McpcatIdentify && - e.isError, + (e) => e.eventType === PublishEventRequestEventTypeEnum.McpcatIdentify, ); - if (identifyEvent) { - expect(identifyEvent.error).toBeDefined(); - expect(identifyEvent.error!.message).toBe("Identify error"); - expect(identifyEvent.error!.type).toBe("Error"); - expect(identifyEvent.error!.stack).toBeDefined(); - expect(identifyEvent.error!.frames).toBeDefined(); - } + expect(identifyEvent).toBeUndefined(); + + // Verify the tool call event was still published + const toolCallEvent = events.find( + (e) => e.eventType === PublishEventRequestEventTypeEnum.mcpToolsCall, + ); + expect(toolCallEvent).toBeDefined(); } finally { await cleanup(); } diff --git a/src/tests/identify.test.ts b/src/tests/identify.test.ts index 3f74afd..e7d09c4 100644 --- a/src/tests/identify.test.ts +++ b/src/tests/identify.test.ts @@ -685,16 +685,13 @@ describe("Identify Feature", () => { // Wait for events await new Promise((resolve) => setTimeout(resolve, 50)); - // Verify identify event was published with error + // Verify NO identify event was published (errors in identify function should not publish events) const events = eventCapture.getEvents(); const identifyEvent = events.find( (e) => e.eventType === PublishEventRequestEventTypeEnum.mcpcatIdentify, ); - expect(identifyEvent).toBeDefined(); - expect(identifyEvent?.isError).toBe(true); - expect(identifyEvent?.error?.message).toContain(errorMessage); - expect(identifyEvent?.duration).toBeDefined(); + expect(identifyEvent).toBeUndefined(); // Verify no user identity was stored const data = getServerTrackingData(server.server); diff --git a/src/tests/report-missing.test.ts b/src/tests/report-missing.test.ts index 25f82de..ef36e43 100644 --- a/src/tests/report-missing.test.ts +++ b/src/tests/report-missing.test.ts @@ -261,7 +261,7 @@ describe("Report Missing Tool", () => { await eventCapture.start(); // Enable tracking - track(server, "proj_0ujtsYcgvSTl8PAuAdqWYSMnLOv"); + track(server, "proj_abc123xyz"); const description = "Need file system watcher tool"; const context = "User wants to monitor file changes in real-time";