Skip to content

Fix file transfer reliability - #96

Merged
ctoth merged 1 commit into
masterfrom
agent/file-transfer-reliability
Jul 30, 2026
Merged

Fix file transfer reliability#96
ctoth merged 1 commit into
masterfrom
agent/file-transfer-reliability

Conversation

@ctoth

@ctoth ctoth commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • make chunk persistence and metadata tracking atomic in one IndexedDB transaction
  • ignore duplicate incoming chunk indexes when accounting progress and persisting data
  • record receive consent before notifying the sender or waiting for the data channel
  • reject backpressured sends when the data channel closes or errors

Root cause and impact

File-transfer state crossed asynchronous boundaries without atomic updates or correctly ordered authorization. Concurrent chunk saves could lose metadata, duplicate chunks could corrupt completion accounting, accepted transfers could reject early valid bytes, and buffered sends could wait forever after transport failure. Together these fixes make incoming and outgoing transfers terminate consistently instead of stalling or discarding accepted data.

TDD evidence

The new regressions failed first on all four behaviors: only 6 of 16 concurrent chunk indexes survived, consent was absent during the channel wait, a duplicate chunk triggered premature integrity failure, and buffered sends registered no close/error handlers. The same focused suite then passed 87/87 after the fixes.

Validation

  • npm test -- src/FileTransferStore.test.ts src/FileTransferManager.test.ts src/WebRTCService.test.ts — 87 passed
  • npm test — 1,052 passed
  • npm run typecheck
  • npm run lint:staged
  • git diff --check

Closes #56
Closes #62
Closes #63
Closes #74

@ctoth
ctoth merged commit 0de252f into master Jul 30, 2026
1 check passed
github-actions Bot pushed a commit that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant