( stream: Stream<BetaRawMessageStreamEvent> | undefined, )
| 2923 | * @internal Exported for testing |
| 2924 | */ |
| 2925 | export function cleanupStream( |
| 2926 | stream: Stream<BetaRawMessageStreamEvent> | undefined, |
| 2927 | ): void { |
| 2928 | if (!stream) { |
| 2929 | return |
| 2930 | } |
| 2931 | try { |
| 2932 | // Abort the stream via its controller if not already aborted |
| 2933 | if (!stream.controller.signal.aborted) { |
| 2934 | stream.controller.abort() |
| 2935 | } |
| 2936 | } catch { |
| 2937 | // Ignore - stream may already be closed |
| 2938 | } |
| 2939 | } |
| 2940 | |
| 2941 | /** |
| 2942 | * Updates usage statistics with new values from streaming API events. |
no outgoing calls
no test coverage detected