Skip to content

Commit

Permalink
Wait for pending publish promise before attempting to unpublish track (
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasIO authored Jul 5, 2024
1 parent 85be969 commit 6db76f4
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/forty-mirrors-compete.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Wait for pending publish promise before attempting to unpublish track
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
with:
version: 8
- name: Use Node.js 20
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/size-limit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
CI_JOB_NUMBER: 1
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
with:
version: 8
- name: Use Node.js 20
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
- uses: pnpm/action-setup@v4
with:
version: 8
- name: Use Node.js 20
Expand Down
10 changes: 10 additions & 0 deletions src/room/participant/LocalParticipant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1022,6 +1022,16 @@ export default class LocalParticipant extends Participant {
track: LocalTrack | MediaStreamTrack,
stopOnUnpublish?: boolean,
): Promise<LocalTrackPublication | undefined> {
if (track instanceof LocalTrack) {
const publishPromise = this.pendingPublishPromises.get(track);
if (publishPromise) {
this.log.info('awaiting publish promise before attempting to unpublish', {
...this.logContext,
...getLogContextFromTrack(track),
});
await publishPromise;
}
}
// look through all published tracks to find the right ones
const publication = this.getPublicationForTrack(track);

Expand Down

0 comments on commit 6db76f4

Please sign in to comment.