Repository navigation
fix: bound Insight, JSON-RPC and faucet requests with deadlines - #38
Conversation
Fetches to Insight, the JSON-RPC InstantSend endpoint and the faucet had no deadline on response headers or body. A server that accepted the connection but never finished could hang deposit detection, or hang the IS-lock wait after broadcast so the 60s timeout and chain-lock fallback were never reached. - Add src/utils/fetch-json.ts, identical to the helper in #37, and a sibling fetchWithDeadline for call sites that need the raw Response. - Insight reads: 8s; broadcast: 20s, keeping its error text. - JSON-RPC getislocks/getbestchainlock: 8s. The IS-lock wait now cancels the in-flight request and settles exactly at its deadline or on caller abort, even mid retry backoff. - Faucet: the existing 30s timeout now also covers the body read; a stalled body after a 2xx tells the user funds may already be sent. - Forward the chain-lock fallback's abort signal to tx polling. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 49 minutes. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (3)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (7)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughRequest utilities and API clients now apply deadlines and cancellation to network requests and response reads. Insight, DAPI, and faucet request flows handle timeout and abort outcomes, with tests covering stalled requests, stalled response bodies, and polling cancellation. ChangesRequest deadlines
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The change is mergeable. In one narrow case, cancelling block-height polling may take a few seconds to finish. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
A broadcast that hits its new deadline may still have reached the node. Failing there skipped setTransactionBroadcast, so the error screen had no txid and hid the chain-lock fallback. Treat timeouts (and the 'already in block chain' reply to a retry of a mined tx) as an unknown outcome and continue to the IS lock wait with the locally computed txid. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Insight, the JSON-RPC InstantSend endpoint and the faucet were called with
await fetch(...)and thenawait response.json(), with no per-request deadline. Elapsed-time and abort checks only ran between requests. A server that accepts the connection but never finishes the headers or the body could therefore hang deposit detection. Worse, it could hang the InstantSend wait after the asset lock had already been broadcast, so the 60s IS-lock timeout and the chain-lock recovery path were never reached. This was reported by a security review (findings 10 and 11, low severity).Change
Every one of those requests now has a deadline that covers both the headers and the body read:
getislocks/getbestchainlockDAPIClient.waitForInstantSendLocknow settles at exactly its deadline, even if the deadline falls during a retry backoff. When it does, it cancels the request that's in flight, so the existing error, recovery and chain-lock fallback paths run.withRetry. That's safe because re-sending the same signed transaction is idempotent.Coordination with #37
src/utils/fetch-json.tsis byte-identical to the helper in #37. That PR is a larger rework that removes the Digital Cash RPC dependency. A simulated merge conflicts only ininsight.ts(imports andgetTransaction) anddapi.ts(waitForInstantSendLock, which #37 rewrites).Testing
npm testpasses, with 17 new tests insrc/utils/fetch-with-deadline.test.tsandsrc/api/request-deadlines.test.ts. They cover:IslockServicethat rejects at exactly 60,000ms;npm run buildandnpm run test:e2epass.🤖 Generated with Claude Code
Summary by CodeRabbit