Skip to content

fix: clear pending timeout in AudioSource.close()#639

Open
LautaroPetaccio wants to merge 3 commits intolivekit:mainfrom
LautaroPetaccio:fix/audio-source-clear-timeout
Open

fix: clear pending timeout in AudioSource.close()#639
LautaroPetaccio wants to merge 3 commits intolivekit:mainfrom
LautaroPetaccio:fix/audio-source-clear-timeout

Conversation

@LautaroPetaccio
Copy link
Copy Markdown

Why

AudioSource.captureFrame() schedules a setTimeout that calls this.release after the current queue drains. close() disposed the native handle and set closed = true, but never cleared the timeout. The callback fires after disposal, referencing freed native state. While not a direct FD leak, it causes use-after-free on the native side that can prevent the handle from being fully released.

How

Before disposing the handle in close(), check for a pending this.timeout and call clearTimeout() + set it to undefined. This prevents the scheduled release callback from firing after the native handle is freed.

Copy link
Copy Markdown

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 2 additional findings in Devin Review.

Open in Devin Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 1, 2026

🦋 Changeset detected

Latest commit: 3c58cf8

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@livekit/rtc-node Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

devin-ai-integration[bot]

This comment was marked as resolved.

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