Repository navigation
fix(client-js): refuse initDevices() once devices are initialized - #281
Closed
mattieruth wants to merge 1 commit into
Closed
mattieruth wants to merge 1 commit into
mattieruth wants to merge 1 commit into
Conversation
initDevices() is intended to be called once, before connect(). The transports already enforce this: daily-js allows a single startCamera(), and DailyMediaManager.initialize() warns and returns if already initialized. PipecatClient did not, so a repeat call re-ran the full MediaState lifecycle against a transport that could not act on it, and a device that was 'blocked' fell back to 'uninitialized' or 'unknown'. Track whether the transport has initialized devices, set when initDevices() resolves or connect() succeeds (transports initialize media as part of connecting, including when every requested device is disabled and the implicit init is skipped). A later initDevices() logs a warning pointing at enableMic() / enableCam() and returns without touching the transport or MediaState, and needsInit() returns false. A rejected initDevices() leaves the flag unset so the call can be retried, matching the transports, which allow another attempt when initialization never completed. Closes #280
filipi87
reviewed
Nov 3, 2026
Comment on lines
+316
to
+318
| // part of connecting). Once a transport has initialized it can't do so | ||
| // again (daily-js allows a single startCamera()), so a later initDevices() | ||
| // is refused here rather than handed down. A rejected initDevices() leaves |
Collaborator
There was a problem hiding this comment.
Just to confirm, is this true for all the transports ? Or could this approach cause some side effects in any of the other transports ?
Collaborator
There was a problem hiding this comment.
I think my question is like, after the disconnect, would any of the other transports require initDevices to be invoked again ?
Contributor
Author
There was a problem hiding this comment.
thank you for asking this question. my memory was wrong on EVERY account. All the transports require initDevices differently. I'm going to close this and it's corresponding issue and look instead into seeing if I can remove the requirement of calling initDevices() at all. Make it more of a convenience. Stay tuned...
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.
initDevices() is intended to be called once, before connect(). The transports already enforce this: daily-js allows a single startCamera(), and DailyMediaManager.initialize() warns and returns if already initialized. PipecatClient did not, so a repeat call re-ran the full MediaState lifecycle against a transport that could not act on it, and a device that was 'blocked' fell back to 'uninitialized' or 'unknown'.
initDevices(). A later initDevices() logs a warning pointing at enableMic() / enableCam() and returns without touching the transport or MediaState. Those methods are now the documented way to retry a device that errored during init.needsInit(). Returns false once initDevices() or connect() has succeeded, even if a requested device is still 'uninitialized' or errored, so connect() won't drive a second implicit init.Fixes
initDevices()should refuse repeat calls #280Release Notes
client-js
Bug Fixes
PipecatClient.initDevices()is now one-time. After it resolves, or afterconnect()succeeds, further calls log a warning and return without calling the transport or changingmediaState. Previously a repeat call re-ran theMediaStatelifecycle against a transport that couldn't initialize again, which could knock a"blocked"device back to"uninitialized"or"unknown". To retry or change a device after initialization, useenableMic(true)/enableCam(true). IfinitDevices()rejected, it can still be called again.needsInit()also returnsfalseonce devices are initialized. (80dd375)