Skip to content

sdk: fix JSON-RPC batch matching#5137

Open
0xjc65eth wants to merge 2 commits into
ClankerNation:mainfrom
0xjc65eth:fix-rpc-batch-ordering-161-v4
Open

sdk: fix JSON-RPC batch matching#5137
0xjc65eth wants to merge 2 commits into
ClankerNation:mainfrom
0xjc65eth:fix-rpc-batch-ordering-161-v4

Conversation

@0xjc65eth
Copy link
Copy Markdown

Fixes #161

/claim #161
Payment: BTC | bc1qjf2t6dc75c6t2948essyrqec0a08l8zl28fcfh | Bitcoin

Summary:

  • Map JSON-RPC batch responses by id and return results in original request order.
  • Preserve JSON-RPC item failures as per-item error objects so one failed item does not fail the whole batch.
  • Return per-item timeout errors when a batch response omits a request id.
  • Add configurable batch fetch timeout and return timeout errors for every request if the batch request is aborted.
  • Add focused tests for shuffled response order, partial failure, missing response timeout, and whole-batch timeout.
  • Add contributor metadata block at the top of the primary modified file plus CONTRIBUTORS.json record.

Verification:

  • npx mocha test/SDKRpcBatchOrdering.test.js -> 4 passing
  • npx tsc --noEmit --ignoreConfig --target ES2020 --module commonjs --types node sdk/src/providers/rpc.ts -> clean
  • node --check test/SDKRpcBatchOrdering.test.js -> clean
  • node -e "JSON.parse(require('fs').readFileSync('CONTRIBUTORS.json','utf8')); console.log('CONTRIBUTORS.json ok')" -> clean
  • git diff --check -> clean

Competing PR review:

  • Reviewed the competing RPC batch implementation and flagged a missing whole-batch timeout path before submitting this PR.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ Bounty $9k ] [ SDK ] Fix rpc.ts doesn't handle JSON-RPC batch response ordering — backwards compat

1 participant