Skip to content

Commit d1b27a9

Browse files
committed
fix(sdk): drop duplicate onError on SSE auth-error path
`SSEStreamSubscription.connectStream` invokes `onError` twice for 401/403 responses: first in the `!response.ok` branch where the auth ApiError is constructed (so consumers see the original failure status/headers), then again in the catch block's `isTriggerRealtimeAuthError` arm before terminating the stream. Drop the second call — the early one already notified the consumer; the catch block's job is just to route the error to `controller.error` so retry doesn't fire. Spotted by Devin on PR 3173.
1 parent 5629d2b commit d1b27a9

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

packages/core/src/v3/apiClient/runStream.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,9 @@ export class SSEStreamSubscription implements StreamSubscription {
431431
}
432432

433433
if (isTriggerRealtimeAuthError(error)) {
434-
this.options.onError?.(error as Error);
434+
// `onError` was already invoked in the `!response.ok` branch above
435+
// (where the auth ApiError was originally constructed and thrown).
436+
// Auth errors are non-retryable: terminate the stream cleanly.
435437
controller.error(error as Error);
436438
return;
437439
}

0 commit comments

Comments
 (0)