Commit 04a3f39
authored
fix(react-client): await pending addTrack to fix track ops race (#527)
## Description
`getCurrentTrackId` now awaits the in-flight `addTrack` promise before
returning, so callers always see the resolved remote track id once the
track is registered.
- Add `connectionPromiseRef` storing the active `addTrack` job
- Make `getCurrentTrackId` async and await pending job
- Update callers (`replaceTrack`, `refreshStreamedTrack`,
`toggleMute`, `toggleDevice`) to await the new async signature
- Await `pauseStreaming` in `toggleDevice`
## Motivation and Context
`startStreaming` set `currentTrackIdRef.current` only after `addTrack`
resolved. If the user invoked `toggleMute`, `replaceTrack`, or
`toggleDevice` during that window, `getCurrentTrackId` returned `null`
and the operation silently no-op'd (mute toggles ignored, replace
skipped). Awaiting the pending promise removes the race.
## Documentation impact
- [ ] Documentation update required
- [ ] Documentation updated [in another PR](_)
- [x] No documentation update required
## Types of changes
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to
not work as expected)1 parent bb70155 commit 04a3f39
1 file changed
Lines changed: 12 additions & 7 deletions
Lines changed: 12 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
43 | 44 | | |
44 | 45 | | |
45 | 46 | | |
46 | | - | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
| |||
57 | 61 | | |
58 | 62 | | |
59 | 63 | | |
60 | | - | |
| 64 | + | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
| |||
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
69 | | - | |
| 73 | + | |
70 | 74 | | |
71 | 75 | | |
72 | 76 | | |
| |||
90 | 94 | | |
91 | 95 | | |
92 | 96 | | |
93 | | - | |
94 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
95 | 100 | | |
96 | 101 | | |
97 | 102 | | |
| |||
119 | 124 | | |
120 | 125 | | |
121 | 126 | | |
122 | | - | |
| 127 | + | |
123 | 128 | | |
124 | 129 | | |
125 | 130 | | |
| |||
139 | 144 | | |
140 | 145 | | |
141 | 146 | | |
142 | | - | |
| 147 | + | |
143 | 148 | | |
144 | 149 | | |
145 | 150 | | |
| |||
0 commit comments