Skip to content

fix(replication): clean up blobs accepted during failed decode#113

Open
kriszyp wants to merge 1 commit into
mainfrom
fix/blob-orphan-cleanup
Open

fix(replication): clean up blobs accepted during failed decode#113
kriszyp wants to merge 1 commit into
mainfrom
fix/blob-orphan-cleanup

Conversation

@kriszyp
Copy link
Copy Markdown
Member

@kriszyp kriszyp commented May 3, 2026

Summary

In the replication ingest loop in replicationConnection.ts, decodeBlobsWithWrites may invoke the blob callback (which kicks off saveBlob via receiveBlobs) for one or more blobs and then throw before the surrounding callback can build the event. The catch only logs, so the partially-accepted blobs end up on disk with no record ever referencing them.

This PR tracks the blobs as they are received and, if event is still undefined after the catch (decode failed), schedules deletion after the same 60s window the relocate path already uses. The successful path is unchanged.

Companion PR

Depends on the matching core PR at HarperFast/harper#462 for the broader transactional orphan cleanup. This change handles one specific path that lives in harper-pro.

Where to look

  • replication/replicationConnection.ts lines 1547–1592 — single hunk; the new code is the receivedBlobs tracker and the post-catch setTimeout.

Test plan

  • Trigger a malformed replication payload in a multi-node cluster, confirm orphan blob count stays at 0.
  • Local replication tests are not in scope of this PR.

🤖 Generated with Claude Code

In the replication ingest loop, `decodeBlobsWithWrites` may invoke the
blob callback (which kicks off `saveBlob`) for one or more blobs and
then throw before the surrounding callback can build the `event`. The
`catch` only logs, so the partial blobs end up on disk with no record
ever referencing them.

Track the blobs as they are received and, if `event` is still
undefined after the catch (decode failed), schedule deletion after the
60s window used by the relocate path. The successful path is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kriszyp kriszyp requested a review from a team as a code owner May 3, 2026 00:48
Copy link
Copy Markdown
Member

@cb1kenobi cb1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants