fix(elements): stop unbounded permission retry loop in mic selector - #466
Open
ephraimduncan wants to merge 1 commit into
Open
fix(elements): stop unbounded permission retry loop in mic selector#466ephraimduncan wants to merge 1 commit into
ephraimduncan wants to merge 1 commit into
Conversation
Denying microphone permission re-triggered getUserMedia indefinitely while the popover stayed open: the loading state was both a callback dependency and an effect guard, so every rejection recreated the callback and re-fired the effect. Replace the effect with an onOpenChange handler that makes at most one automatic permission request per popover open. Track in-flight loads with a ref so both loader callbacks have stable identity. Denial now settles into a stable error; reopening or calling loadDevices is the retry boundary.
Contributor
|
@ephraimduncan is attempting to deploy a commit to the Vercel Team on Vercel. A member of the Team first needs to authorize it. |
| }); | ||
| const [width, setWidth] = useState(200); | ||
| const { devices, loading, hasPermission, loadDevices } = useAudioDevices(); | ||
| const { devices, hasPermission, loadDevices } = useAudioDevices(); |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Denying microphone permission while the
MicSelectorpopover was open caused endless repeated permission attempts and console error spam; a denial now settles into a single stable error. Theloadingstate was both a dependency of the permission callback and the guard of the auto-request effect, so every rejection recreated the callback and re-fired the request. The automatic request now happens in the popover's open handler instead — at most one per open — and a denial is retried only by reopening the popover or callingloadDevices()explicitly (policy documented in the component docs). One behavior nuance: a popover that is already open on first render (defaultOpenor controlledopen) no longer auto-requests on mount; requests fire on actual open events.The new regression test was verified against the previous implementation, where it fails with an unbounded
getUserMediacall count, and passes with the fix (31/31 in the suite).