fix(docsync): an orphaned binding stays stopped on every path that starts a run

This commit is contained in:
Maurice
2026-09-19 21:57:04 +02:00
parent 83c9cebddc
commit 3ad40e056d
9 changed files with 146 additions and 7 deletions
@@ -112,6 +112,7 @@ export class DocSyncService {
.prepare(
`SELECT * FROM trip_document_links
WHERE sync_enabled = 1
AND last_sync_state != 'orphaned'
AND failure_count < ?
AND (next_attempt_at IS NULL OR next_attempt_at <= CURRENT_TIMESTAMP)
AND provider_id IN (SELECT id FROM document_providers WHERE enabled = 1)
@@ -176,6 +177,12 @@ export class DocSyncService {
if (this.isSwitchedOff(link)) {
return { state: 'disabled', pulled: 0, pushed: 0, conflicts: 0, missing: 0 };
}
// An orphaned binding runs for nobody. Its credential belongs to somebody
// who has left the trip, and a webhook or a resolved conflict reach this
// without asking beforehand.
if (this.config.isOrphaned(link)) {
return { state: 'orphaned', pulled: 0, pushed: 0, conflicts: 0, missing: 0 };
}
const conn = this.config.getConnection(link.connection_id);
if (!conn) {
this.recordLinkFailure(link, 'not_found');