Skip to content

Commit ee84bce

Browse files
mxmzbclaude
andcommitted
fix: harden subscribeToAgent with try-catch and add core-level tests
Address review findings from PR CopilotKit#3734: - Wrap flushPending callback invocations in try-catch so a thrown exception in onMessagesChanged/onStateChanged does not permanently deadlock the throttle state machine or skip the sibling flush - Add 21 dedicated unit tests for CopilotKitCore.subscribeToAgent covering leading/trailing edge, shared window (bidirectional), burst coalescing, run lifecycle passthrough, unsubscribe cleanup, resolution cascade, invalid values, and exception safety - Use named CopilotKitCoreSubscription return type - Fix Angular test stub to accept the options parameter and document that it bypasses throttle logic Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f1fc008 commit ee84bce

3 files changed

Lines changed: 607 additions & 4 deletions

File tree

packages/angular/src/lib/agent.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ class CopilotKitStub {
8383
runtimeTransport: "auto" as const,
8484
runtimeConnectionStatus: CopilotKitCoreRuntimeConnectionStatus.Disconnected,
8585
headers: {} as Record<string, string>,
86-
subscribeToAgent: (agent: any, subscriber: any) =>
86+
// Passthrough stub — does not implement throttle logic.
87+
// Throttle behavior is covered by core-level unit tests.
88+
subscribeToAgent: (agent: any, subscriber: any, _options?: any) =>
8789
agent.subscribe(subscriber),
8890
};
8991

0 commit comments

Comments
 (0)