fix(replication): clean up blobs accepted during failed decode#113
Open
kriszyp wants to merge 1 commit into
Open
fix(replication): clean up blobs accepted during failed decode#113kriszyp wants to merge 1 commit into
kriszyp wants to merge 1 commit into
Conversation
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>
DavidCockerill
approved these changes
May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In the replication ingest loop in
replicationConnection.ts,decodeBlobsWithWritesmay invoke the blob callback (which kicks offsaveBlobviareceiveBlobs) for one or more blobs and then throw before the surrounding callback can build theevent. Thecatchonly 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
eventis 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.tslines 1547–1592 — single hunk; the new code is thereceivedBlobstracker and the post-catchsetTimeout.Test plan
🤖 Generated with Claude Code