@@ -206,7 +206,8 @@ function schedulePostConnectWarnings(
206206
207207 if ( decision . shouldWatch && attempt . watch ) {
208208 const watchRef = attempt . watch ;
209- attempt . healthEffect . timeout ( ( ) => {
209+ // Use setTimeout instead of healthEffect.timeout() which fires immediately
210+ setTimeout ( ( ) => {
210211 if ( get ( ) . status !== 'connected' ) return ;
211212 if ( watchRef . status . peek ( ) !== 'live' ) {
212213 set ( {
@@ -218,15 +219,23 @@ function schedulePostConnectWarnings(
218219
219220 if ( decision . shouldPublish && attempt . microphone ) {
220221 const microphoneRef = attempt . microphone ;
221- attempt . healthEffect . timeout ( ( ) => {
222+
223+ // Track if the microphone source was EVER acquired during the 10-second window.
224+ // This prevents false errors when the source signal transiently goes falsy.
225+ let wasEverReady = Boolean ( microphoneRef . source . peek ( ) ) || get ( ) . micStatus === 'ready' ;
226+ attempt . healthEffect . subscribe ( microphoneRef . source , ( value ) => {
227+ if ( value ) wasEverReady = true ;
228+ } ) ;
229+
230+ // Use setTimeout instead of healthEffect.timeout() which fires immediately
231+ setTimeout ( ( ) => {
222232 if ( get ( ) . status !== 'connected' ) return ;
223- if ( ! microphoneRef . source . peek ( ) ) {
224- set ( {
225- micStatus : 'error' ,
226- errorMessage :
227- 'Connected to relay, but microphone is not available. Check browser permissions and selected input device.' ,
228- } ) ;
229- }
233+ if ( wasEverReady ) return ;
234+ set ( {
235+ micStatus : 'error' ,
236+ errorMessage :
237+ 'Connected to relay, but microphone is not available. Check browser permissions and selected input device.' ,
238+ } ) ;
230239 } , 10_000 ) ;
231240 }
232241}
0 commit comments