Commit 34b330a
committed
fix(react): guard processor cast and detach on cleanup
Two correctness fixes from PR review:
- Guard the `KrispNoiseFilterProcessor` cast in the returned `processor`
value with a `name === 'livekit-noise-filter'` check. The
unconditional cast assumed nothing else could attach a
`TrackProcessor` to the track; if anything did, the hook handed
consumers a value typed as a Krisp processor that wasn't one.
- Add a separate cleanup effect that detaches the processor we own
when the underlying track changes or the hook unmounts. Tracks the
attached processor + its track via refs so cleanup can verify
identity (`track.getProcessor() === processor`) before calling
`stopProcessor()` — avoids accidentally detaching a Krisp processor
that some other module owns. Refs are populated only after
`setProcessor` lands, so a cancelled mid-attach leaves them clear.
Closes the gap where the track outlives the hook (caller-owned
`trackRef` unmount or in-place swap to a different live track),
while leaving the existing toggle-reuse path on `shouldEnable`
unchanged.1 parent 63fa161 commit 34b330a
2 files changed
Lines changed: 38 additions & 5 deletions
File tree
- .changeset
- packages/react/src/hooks/cloud/krisp
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
Lines changed: 37 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
51 | 54 | | |
52 | 55 | | |
53 | 56 | | |
| |||
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
108 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
109 | 114 | | |
110 | 115 | | |
| 116 | + | |
| 117 | + | |
111 | 118 | | |
112 | 119 | | |
113 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
114 | 127 | | |
115 | 128 | | |
116 | 129 | | |
| |||
126 | 139 | | |
127 | 140 | | |
128 | 141 | | |
129 | | - | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
130 | 159 | | |
131 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
132 | 165 | | |
133 | 166 | | |
134 | 167 | | |
| |||
0 commit comments