Skip to content

Release live request abort listeners when each request ends - #233

Open
codebanditssss wants to merge 1 commit into
AssemblyAI:mainfrom
codebanditssss:fix/live-deadline-signal-listeners
Open

codebanditssss wants to merge 1 commit into
AssemblyAI:mainfrom
codebanditssss:fix/live-deadline-signal-listeners

Conversation

@codebanditssss

Copy link
Copy Markdown

Fixes #232.

deadlineSignal() now returns { signal, release }. release() removes the listeners on the caller's signal and the timeout. sync.transcribe(), sync.transcribeLive(), sync.openLive(), dictation.transcribeLive() and dictation.openLive() call it in finally after postLive(). postLive() reads the response body before returning, so cancellation and the timeout still cover the whole request.

Tests

tests/unit/live-deadline-signal.test.ts uses a real local HTTP server and fetch. It covers successful and rejected requests, aborting mid-request, the timeout alongside a signal, two requests sharing one signal, aborting while a partial response body is being read, and openLive().

  • Unchanged source: listeners left 20 / 6 / 1 in the three leak cases. Fixed: 0.
  • 16,000 requests on one shared signal: base leaves 16,000 listeners and ~31 MB of heap growth; fixed leaves 0 listeners and ~5 MB.
  • Full unit suite: 590 passed (with --no-experimental-global-navigator; default Node 22 still has the 3 existing user-agent failures). eslint, tsc, prettier, build and publint pass.

Bumps the version to 4.43.6, since #230 and #231 use 4.43.5.

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.

Sync and dictation requests leave an abort listener on a shared options.signal

1 participant