A comparison screen needs a deadline for the overall search, not just separate long timeouts on every upstream request. Otherwise one slow provider controls the user's entire wait.
Budget the whole operation
Choose a request budget based on measured user experience and infrastructure behavior. Reserve part of it for parsing and validation. Give each provider a deadline no later than the overall deadline, then collect successful results until the budget closes.
This is an application design choice, not a benchmark or a claim about any provider's speed. PancakeSwap exposes a maxWaitMs parameter with documented engine waiting behavior, but an external multi-provider client still needs its own boundary.
Represent partial results
Return result status per provider: quoted, no route, unsupported, timed out or failed. Rank only valid comparable quotes. Label the result as the best among responses received rather than an absolute market-wide optimum.
Use request cancellation to stop unnecessary work when the deadline passes or the trade changes. A timed-out quote arriving later should not silently replace the route the user has already reviewed.
Do not race directly to execution
Once a user chooses a result, obtain any required fresh executable payload and validate it. The fastest price response might still require approval or separate encoding. A later quote improvement is an invitation for a new review, not permission to swap the transaction behind an open wallet prompt.
Test one hung provider, one immediate no-route response and one valid response near the deadline. Confirm that the screen becomes usable, explains its coverage and never carries stale results into a new trade.
Sources & verification (2)
Source-check date is recorded in the article details. URLs are provided for manual verification. Use Copy to keep this page open.
- Endpoints
Quote, calldata, submit and status contracts
https://developer.pancakeswap.finance/contracts/unified-swap-api/endpoints - AbortController
Abortable requests and response consumption
https://developer.mozilla.org/en-US/docs/Web/API/AbortController