A backup whose lock is lost dies with a stack trace #184

Closed
opened 2026-10-14 01:31:47 +02:00 by clawbot · 1 comment
Collaborator

Problem

lockBackupDirectory in src/backup.ts calls proper-lockfile without an onCompromised handler. The library's default handler throws from inside a timer, which ends the process with a raw stack trace. This happens when the lock is lost while a backup runs: backup.lock is removed, or a second backup takes it over after it went 10 seconds without being touched (the first process was stopped or stalled). Reproduced on next at 2402ec9: take the lock with lockBackupDirectory, remove backup.lock, and within seconds the process dies in proper-lockfile's default onCompromised, printing an ECOMPROMISED stack trace. Every other error in quak is printed as one line (src/cli-run.ts).

Definition of done

  • When the lock is lost, the backup stops before it starts another file, and quak backup prints one line, quak: lost the lock on DIR: REASON, with no stack trace, and exits 1. lib.backup() rejects with an error saying the same.
  • Library code never calls process.exit and never throws from a timer.
  • Tests: removing backup.lock during a backup stops it with that error; a backup whose lock stays held runs to the end as before.
  • README ("Backup layout", the paragraph on backup.lock) says what happens when the lock is lost.

Model: opus-5-5

## Problem `lockBackupDirectory` in `src/backup.ts` calls proper-lockfile without an `onCompromised` handler. The library's default handler throws from inside a timer, which ends the process with a raw stack trace. This happens when the lock is lost while a backup runs: `backup.lock` is removed, or a second backup takes it over after it went 10 seconds without being touched (the first process was stopped or stalled). Reproduced on `next` at `2402ec9`: take the lock with `lockBackupDirectory`, remove `backup.lock`, and within seconds the process dies in proper-lockfile's default `onCompromised`, printing an `ECOMPROMISED` stack trace. Every other error in quak is printed as one line (`src/cli-run.ts`). ## Definition of done - When the lock is lost, the backup stops before it starts another file, and `quak backup` prints one line, `quak: lost the lock on DIR: REASON`, with no stack trace, and exits 1. `lib.backup()` rejects with an error saying the same. - Library code never calls `process.exit` and never throws from a timer. - Tests: removing `backup.lock` during a backup stops it with that error; a backup whose lock stays held runs to the end as before. - README ("Backup layout", the paragraph on `backup.lock`) says what happens when the lock is lost. Model: opus-5-5
clawbot added this to the 1.0.0 milestone 2026-10-14 01:33:13 +02:00
Author
Collaborator

Built in #193: the lock records why it was lost instead of throwing from proper-lockfile's timer, and the backup stops before its next original with lost the lock on DIR: REASON, printed by quak backup as one line with exit 1.

Model: opus-5-5

Built in https://git.eeqj.de/sneak/quak/pulls/193: the lock records why it was lost instead of throwing from proper-lockfile's timer, and the backup stops before its next original with `lost the lock on DIR: REASON`, printed by `quak backup` as one line with exit 1. Model: opus-5-5
Sign in to join this conversation.