Skip to content

Fix connection leaks: Ensure that any pending connection open are cancelled/undo when ActiveCall is unmounted #3255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 14, 2025

Conversation

BillCarsonFr
Copy link
Member

@BillCarsonFr BillCarsonFr commented May 9, 2025

Fixes #3268

AudioCaptureOptions was a different object but with same internal values, use directly deviceId so that Object.is works properly
@BillCarsonFr BillCarsonFr added the PR-Bug-Fix Release note category. A PR that fixes a bug. label May 9, 2025
Copy link
Contributor

@toger5 toger5 left a comment

Choose a reason for hiding this comment

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

Looking good.
I think renaming would make sense. (If cancellable is from "able to cancel" its spelled wrong?)

// Protection against potential leaks, where the component to be unmounted and there is
// still a pending doConnect promise. This would lead the user to still be in the call even
// if the component is unmounted.
const cancelBag = useRef(new Set<Cancellable>());
Copy link
Contributor

Choose a reason for hiding this comment

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

abortHandles?

{
deviceId: initialDevices.current.audioInput.selectedId,
},
initialDevices.current.audioInput.selectedId,
Copy link
Contributor

Choose a reason for hiding this comment

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

Really good that you detected and fixed this!

Comment on lines 8 to 18
export class Cancellable {
public constructor(private cancelled = false) {}

public cancel(): void {
this.cancelled = true;
}

public isCancelled(): boolean {
return this.cancelled;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
export class Cancellable {
public constructor(private cancelled = false) {}
public cancel(): void {
this.cancelled = true;
}
public isCancelled(): boolean {
return this.cancelled;
}
}
export class AbortHandle {
public constructor(private aborted = false) {}
public abort(): void {
this.aborted = true;
}
public isAborted(): boolean {
return this.aborted;
}
}

@toger5 toger5 merged commit 86d8063 into livekit May 14, 2025
32 checks passed
toger5 added a commit that referenced this pull request May 14, 2025
…celled/undo when ActiveCall is unmounted (#3255)

* Better logs for connection/component lifecycle

* fix: `AudioCaptureOptions` was causing un-necessary effect render

AudioCaptureOptions was a different object but with same internal values, use directly deviceId so that Object.is works properly

* fix: Livekit openned connection leaks

* review: rename to AbortHandles

* review: rename variable

---------

Co-authored-by: Timo <[email protected]>
toger5 added a commit that referenced this pull request May 14, 2025
…celled/undo when ActiveCall is unmounted (#3255) (#3269)

* Better logs for connection/component lifecycle

* fix: `AudioCaptureOptions` was causing un-necessary effect render

AudioCaptureOptions was a different object but with same internal values, use directly deviceId so that Object.is works properly

* fix: Livekit openned connection leaks

* review: rename to AbortHandles

* review: rename variable

---------

Co-authored-by: Valere Fedronic <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Bug-Fix Release note category. A PR that fixes a bug. X-Release-Blocker
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Potential race causing a re-connection to livekit after the component is unmounted.
3 participants