Skip to content

fix(document): avoid premature partial search on missing RPC responses#9

Open
Faolain wants to merge 3 commits intomasterfrom
fix/search-convergence-under-churn
Open

fix(document): avoid premature partial search on missing RPC responses#9
Faolain wants to merge 3 commits intomasterfrom
fix/search-convergence-under-churn

Conversation

@Faolain
Copy link
Owner

@Faolain Faolain commented Feb 7, 2026

Links:

What this does:

  • When distributed search encounters missing RPC shard responses, the iterator can prematurely conclude it is done, causing silent short-reads (the ci:part2 flake signature: "Failed to collect all messages X < Y. Log lengths: [...]").
  • This change surfaces missing shard info on MissingResponsesError and prevents the search iterator from marking itself done when missing responses occurred during a fetch.

Changes:

  • packages/programs/data/document/document/src/search.ts
    • Align remote.timeout with remote.wait.timeout (if wait provided and remote.timeout not set)
    • Expose onMissingResponses hook internally and ensure missing responses keep the iterator open (unsetDone + hasMore=true)
  • packages/programs/rpc/src/utils.ts
    • MissingResponsesError now carries missingGroups metadata
  • packages/programs/rpc/test/index.spec.ts
    • Adds a narrow regression test for missingGroups

Local verification:

  • PASS: pnpm --filter @peerbit/rpc test -- --grep "reports missing groups on timeout"
  • PASS: (stress) for i in {1..25}; do PEERBIT_TEST_SESSION=mock pnpm --filter @peerbit/document test -- --grep "can search while keeping minimum amount of replicas" || break; done
    • 25/25 passed locally on this branch.

@Faolain
Copy link
Owner Author

Faolain commented Feb 7, 2026

AI Review (and yelling at me for asking it to repeat tests)
Screenshot 2026-02-06 at 8 38 46 PM

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.

1 participant