Skip to content

PeerStorage.delete() treats ENOENT as failure, spamming logs during catch-up #57

Description

@pike00

Summary

PeerStorage.delete() catches all exceptions from Deno.remove() and logs "delete failed" at LOG_LEVEL_NOTICE, returning false. When CouchDB tombstones arrive for paths that were already removed while the bridge was down (or never existed on this host), ENOENT is expected — the file is already gone. Treating it as a failure spams the log and returns false to the caller, which may affect downstream retry logic.

Reproduction

  1. Delete a file on machine A while the bridge on machine B is down.
  2. Start the bridge on machine B.
  3. The CouchDB change feed delivers a tombstone for the deleted path.
  4. PeerStorage.delete() calls Deno.remove()ENOENT → logs "delete failed" at NOTICE level.

Fix

Catch Deno.errors.NotFound specifically and return true — the file is already absent, which is the desired end state.

 async delete(pathSrc: string): Promise<boolean> {
     try {
         await Deno.remove(path);
         this.receiveLog(\` ${path} deleted\`);
     } catch (ex) {
+        if (ex instanceof Deno.errors.NotFound) {
+            this.receiveLog(\` ${path} already absent\`);
+            return true;
+        }
         this.receiveLog(\` ${path} delete failed\`, LOG_LEVEL_NOTICE);
         Logger(ex, LOG_LEVEL_VERBOSE);
         return false;
     }
 }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions