Skip to content

Share overlapping streaming close calls - #230

Open
codebanditssss wants to merge 1 commit into
AssemblyAI:mainfrom
codebanditssss:audit/concurrent-streaming-close
Open

codebanditssss wants to merge 1 commit into
AssemblyAI:mainfrom
codebanditssss:audit/concurrent-streaming-close

Conversation

@codebanditssss

Copy link
Copy Markdown

Summary

Share one in-flight StreamingTranscriber.close() across overlapping callers. The first call's termination-wait options apply, and every caller gets the same result. Include regression tests and the required version/changelog update.

Each close currently replaces sessionTerminatedResolve and sends another Terminate. An earlier waiter can hang, or a later teardown can call .close() on a socket already cleared by another call.

Reproduction

On an established session, call close(true, 0) twice before the server replies with Termination. The earlier call stays pending. With finite timeouts, overlapping callers can instead throw TypeError: Cannot read properties of undefined (reading 'close').

Six regression cases cover overlapping waits, timeout, mixed policies, repeated non-waiting closes, and a fresh close after completion.

Validation

  • Real local TLS WebSocket: baseline failed 4 of 10 calls; fixed passed all 10, with one Terminate per session.
  • Focused close/streaming suites: 82 passed.
  • Full unit suite with NODE_OPTIONS=--no-experimental-global-navigator: 589 passed.
  • Build, eslint, TypeScript, formatting and publint pass, with existing warnings.
  • Default Node 22 runs retain the same three user-agent failures as unchanged upstream. The flag isolates that baseline incompatibility.
  • No paid API or integration tests were run.

PR #169 covers missing Termination, #192 covers close during connect, and #214 adds termination results. None shares overlapping established-session close calls.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant