-
Notifications
You must be signed in to change notification settings - Fork 30
[Enhancement] Add unit tests for GatewayDispatcher error handling logic #227
Copy link
Copy link
Open
Labels
area/dxObservability & DX WGObservability & DX WGarea/gatewayGateway Integration WGGateway Integration WGenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed
Description
What problem are you trying to solve?
GatewayDispatcher contains critical error deduplication and lifecycle buffering logic (shouldDisplayError, isSameFailure, lifecycleErrorBuffer) that currently has zero test coverage. These are some of the most bug-prone code paths in the app — they handle error display, deduplication, and a 2-second buffering window — but any regression would go unnoticed.
Where
- Source:
packages/core/src/services/gateway-dispatcher.ts - Test directory:
packages/core/currently has notest/directory — you will need to create one
What needs to be done
- Create
packages/core/test/gateway-dispatcher.test.ts - Extract
shouldDisplayErrorandisSameFailureas pure testable functions (or test them through the dispatcher) - Write tests covering:
isSameFailure: returns true for identical error codes/messages, false for different onesshouldDisplayError: respects the lifecycle error buffer (errors within the 2s window after a lifecycle event are suppressed)shouldDisplayError: does not suppress errors whenchat.stateis alreadyerror- The buffer timer: after 2s, buffered errors are released
- Use
vi.useFakeTimers()for the buffer window tests - Run
pnpm checkto verify
Why does this matter?
Error display logic is invisible when it works and catastrophic when it breaks — users either get spammed with duplicate errors or see no errors at all. Tests here prevent both failure modes.
Primary area
Task execution
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/dxObservability & DX WGObservability & DX WGarea/gatewayGateway Integration WGGateway Integration WGenhancementNew feature or requestNew feature or requesthelp wantedExtra attention is neededExtra attention is needed