1- import { logger } from '@powersync/lib-services-framework' ;
1+ import { container , logger } from '@powersync/lib-services-framework' ;
22import { AbstractReplicator } from './AbstractReplicator.js' ;
33import { ConnectionTestResult } from './ReplicationModule.js' ;
44
55export class ReplicationEngine {
66 private readonly replicators : Map < string , AbstractReplicator > = new Map ( ) ;
7+ private probeInterval : NodeJS . Timeout | null = null ;
78
89 /**
910 * Register a Replicator with the engine
@@ -27,6 +28,17 @@ export class ReplicationEngine {
2728 logger . info ( `Starting Replicator: ${ replicator . id } ` ) ;
2829 replicator . start ( ) ;
2930 }
31+ if ( this . replicators . size == 0 ) {
32+ // If a replicator is running, the replicators update the probes.
33+ // If no connections are configured, then no replicator is running
34+ // Typical when no connections are configured.
35+ // In this case, update the probe here to avoid liveness probe failures.
36+ this . probeInterval = setInterval ( ( ) => {
37+ container . probes . touch ( ) . catch ( ( e ) => {
38+ logger . error ( `Failed to touch probe` , e ) ;
39+ } ) ;
40+ } , 5_000 ) ;
41+ }
3042 logger . info ( 'Successfully started Replication Engine.' ) ;
3143 }
3244
@@ -39,6 +51,9 @@ export class ReplicationEngine {
3951 logger . info ( `Stopping Replicator: ${ replicator . id } ` ) ;
4052 await replicator . stop ( ) ;
4153 }
54+ if ( this . probeInterval ) {
55+ clearInterval ( this . probeInterval ) ;
56+ }
4257 logger . info ( 'Successfully shut down Replication Engine.' ) ;
4358 }
4459
0 commit comments