@@ -185,7 +185,8 @@ export const make = Effect.gen(function* () {
185185 yield * stopConnector ( active ) ;
186186 } ) ;
187187
188- const superviseConnector = Effect . fn ( "ManagedEndpointRuntime.superviseConnector" ) (
188+ // Lives until connector exit and starts replacements; avoid nested lifetime spans.
189+ const superviseConnector = Effect . fnUntraced (
189190 function * ( connector : ActiveConnector ) {
190191 const result = yield * Effect . result ( connector . child . exitCode ) ;
191192 const activeAtExit = yield * Ref . get ( activeRef ) ;
@@ -370,7 +371,8 @@ export const make = Effect.gen(function* () {
370371 yield * Effect . forkIn ( retryPinnedRelayClientInstall , runtimeScope ) ;
371372 } ) ;
372373
373- const watchConnectorRegistration = Effect . fn ( "ManagedEndpointRuntime.watchConnectorRegistration" ) (
374+ // Registration retries can last for the connector lifetime; keep this loop untraced.
375+ const watchConnectorRegistration = Effect . fnUntraced (
374376 function * ( connector : ActiveConnector ) {
375377 yield * Effect . sleep ( CONNECTOR_REGISTRATION_TIMEOUT ) ;
376378 if ( yield * Deferred . isDone ( connector . registered ) ) return true ;
@@ -389,44 +391,43 @@ export const make = Effect.gen(function* () {
389391 ) ;
390392
391393 // Only an explicit 503 counts: a failed request says nothing about the
392- const watchConnectorReadiness = Effect . fn ( "ManagedEndpointRuntime.watchConnectorReadiness" ) (
393- function * ( connector : ActiveConnector ) {
394- const readyUrl = `http://${ yield * Deferred . await ( connector . metricsAddress ) } /ready` ;
395- let notReadyChecks = 0 ;
396- while ( true ) {
397- yield * Effect . sleep ( CONNECTOR_READINESS_INTERVAL ) ;
398- const status = yield * httpClient . get ( readyUrl ) . pipe (
399- Effect . map ( ( response ) => response . status ) ,
400- Effect . scoped ,
401- Effect . withTracerEnabled ( false ) ,
402- Effect . timeoutOption ( CONNECTOR_READINESS_REQUEST_TIMEOUT ) ,
403- Effect . orElseSucceed ( ( ) => Option . none < number > ( ) ) ,
404- ) ;
405- if ( Option . isNone ( status ) ) continue ;
406- if ( status . value === 200 ) {
407- notReadyChecks = 0 ;
408- yield * Ref . set ( notReadyChecksBeforeRestartRef , CONNECTOR_NOT_READY_CHECKS_BEFORE_RESTART ) ;
409- continue ;
410- }
411- if ( status . value !== 503 ) continue ;
412- notReadyChecks += 1 ;
413- const threshold = yield * Ref . get ( notReadyChecksBeforeRestartRef ) ;
414- if ( notReadyChecks < threshold ) continue ;
394+ // Readiness polling runs for the connector lifetime; keep this loop untraced.
395+ const watchConnectorReadiness = Effect . fnUntraced ( function * ( connector : ActiveConnector ) {
396+ const readyUrl = `http://${ yield * Deferred . await ( connector . metricsAddress ) } /ready` ;
397+ let notReadyChecks = 0 ;
398+ while ( true ) {
399+ yield * Effect . sleep ( CONNECTOR_READINESS_INTERVAL ) ;
400+ const status = yield * httpClient . get ( readyUrl ) . pipe (
401+ Effect . map ( ( response ) => response . status ) ,
402+ Effect . scoped ,
403+ Effect . withTracerEnabled ( false ) ,
404+ Effect . timeoutOption ( CONNECTOR_READINESS_REQUEST_TIMEOUT ) ,
405+ Effect . orElseSucceed ( ( ) => Option . none < number > ( ) ) ,
406+ ) ;
407+ if ( Option . isNone ( status ) ) continue ;
408+ if ( status . value === 200 ) {
415409 notReadyChecks = 0 ;
416- yield * Ref . set (
417- notReadyChecksBeforeRestartRef ,
418- Math . min ( threshold * 2 , CONNECTOR_NOT_READY_CHECKS_MAX ) ,
419- ) ;
420- yield * Effect . logWarning ( "Relay client has no tunnel connection; restarting it" , {
421- pid : Number ( connector . child . pid ) ,
422- notReadyChecks : threshold ,
423- tunnelId : connector . config . tunnelId ,
424- tunnelName : connector . config . tunnelName ,
425- } ) ;
426- yield * connector . child . kill ( ) . pipe ( Effect . ignore ) ;
410+ yield * Ref . set ( notReadyChecksBeforeRestartRef , CONNECTOR_NOT_READY_CHECKS_BEFORE_RESTART ) ;
411+ continue ;
427412 }
428- } ,
429- ) ;
413+ if ( status . value !== 503 ) continue ;
414+ notReadyChecks += 1 ;
415+ const threshold = yield * Ref . get ( notReadyChecksBeforeRestartRef ) ;
416+ if ( notReadyChecks < threshold ) continue ;
417+ notReadyChecks = 0 ;
418+ yield * Ref . set (
419+ notReadyChecksBeforeRestartRef ,
420+ Math . min ( threshold * 2 , CONNECTOR_NOT_READY_CHECKS_MAX ) ,
421+ ) ;
422+ yield * Effect . logWarning ( "Relay client has no tunnel connection; restarting it" , {
423+ pid : Number ( connector . child . pid ) ,
424+ notReadyChecks : threshold ,
425+ tunnelId : connector . config . tunnelId ,
426+ tunnelName : connector . config . tunnelName ,
427+ } ) ;
428+ yield * connector . child . kill ( ) . pipe ( Effect . ignore ) ;
429+ }
430+ } ) ;
430431
431432 const observeConnectorOutput = ( connector : ActiveConnector ) => {
432433 let rejectedRegistrations = 0 ;
0 commit comments