Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/orange-forks-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/service-core': patch
---

Fix liveness probe when no connections are defined.
17 changes: 16 additions & 1 deletion packages/service-core/src/replication/ReplicationEngine.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { logger } from '@powersync/lib-services-framework';
import { container, logger } from '@powersync/lib-services-framework';
import { AbstractReplicator } from './AbstractReplicator.js';
import { ConnectionTestResult } from './ReplicationModule.js';

export class ReplicationEngine {
private readonly replicators: Map<string, AbstractReplicator> = new Map();
private probeInterval: NodeJS.Timeout | null = null;

/**
* Register a Replicator with the engine
Expand All @@ -27,6 +28,17 @@ export class ReplicationEngine {
logger.info(`Starting Replicator: ${replicator.id}`);
replicator.start();
}
if (this.replicators.size == 0) {
// If a replicator is running, the replicators update the probes.
// If no connections are configured, then no replicator is running
// Typical when no connections are configured.
// In this case, update the probe here to avoid liveness probe failures.
this.probeInterval = setInterval(() => {
container.probes.touch().catch((e) => {
logger.error(`Failed to touch probe`, e);
});
}, 5_000);
}
logger.info('Successfully started Replication Engine.');
}

Expand All @@ -39,6 +51,9 @@ export class ReplicationEngine {
logger.info(`Stopping Replicator: ${replicator.id}`);
await replicator.stop();
}
if (this.probeInterval) {
clearInterval(this.probeInterval);
}
logger.info('Successfully shut down Replication Engine.');
}

Expand Down