Repository navigation
fix(explorer): show 'no results found' instead of hanging on an unfetchable tx - #7783
Conversation
getTxOrders races the prod and staging (barn) order lookups with Promise.any, but only the barn leg was wrapped in a timeout. Promise.any stays pending until a promise fulfils or all reject, so when the prod request never responds (an "impossible to fetch" tx), the race never settles: isLoading stays true and the tx-details view is stuck on "Loading transaction details" forever, never redirecting to the SearchNotFound screen. Wrap the prod leg in the same 12s timeout as barn. A hanging prod request now rejects on timeout, the race resolves ([] when the other env is empty), and the existing empty-result path redirects to "no results found".
|
@tenderdeve is attempting to deploy a commit to the cow-dev Team on Vercel. A member of the Team first needs to authorize it. |
WalkthroughAdds a ChangesPROD Timeout Fix
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 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 |
|
Cloudflare Pages preview mirror Preview branch URL: https://github.com/cowprotocol/cowswap/tree/cf-preview/pr-7783 Source fork branch:
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/explorer/src/api/operator/operatorApi.ts (1)
22-29: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueConsider consolidating
withBarnTimeout/withProdTimeout.Both helpers are identical apart from the hardcoded env label; a single parameterized helper would remove the duplication.
♻️ Optional consolidation
-function withBarnTimeout<T>(promise: Promise<T>, operation: string): Promise<T> { - return withTimeout(promise, ENV_REQUEST_TIMEOUT_MS, `${operation}: BARN`) -} - -function withProdTimeout<T>(promise: Promise<T>, operation: string): Promise<T> { - return withTimeout(promise, ENV_REQUEST_TIMEOUT_MS, `${operation}: PROD`) -} +function withEnvTimeout<T>(promise: Promise<T>, operation: string, env: 'PROD' | 'BARN'): Promise<T> { + return withTimeout(promise, ENV_REQUEST_TIMEOUT_MS, `${operation}: ${env}`) +}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/explorer/src/api/operator/operatorApi.ts` around lines 22 - 29, Consolidate the duplicated timeout wrappers in operatorApi.ts by replacing withBarnTimeout and withProdTimeout with a single parameterized helper that accepts the env label and delegates to withTimeout; keep the existing behavior by passing the appropriate label string where each helper is currently used, and update any call sites to use the shared helper instead of two near-identical functions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@apps/explorer/src/api/operator/operatorApi.ts`:
- Around line 22-29: Consolidate the duplicated timeout wrappers in
operatorApi.ts by replacing withBarnTimeout and withProdTimeout with a single
parameterized helper that accepts the env label and delegates to withTimeout;
keep the existing behavior by passing the appropriate label string where each
helper is currently used, and update any call sites to use the shared helper
instead of two near-identical functions.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 816433a4-7ec0-4e58-922d-cb3e62d829a0
📒 Files selected for processing (2)
apps/explorer/src/api/operator/operatorApi.tsapps/explorer/src/test/api/operator/operatorApi.test.ts
Fixes #7390
Searching a tx whose details can't be fetched leaves the explorer stuck on "Loading transaction details" forever instead of showing the SearchNotFound screen.
getTxOrdersraces the prod and staging (barn) lookups withPromise.any, but only the barn leg had a timeout.Promise.anystays pending until one promise fulfils or all reject, so when the prod request never responds, the race never settles —isLoadingstays true and the widget's redirect-to-SearchNotFound (which is gated on!isLoading) can never fire.Wrap the prod leg in the same 12s timeout as barn (
withProdTimeout). A hanging prod request now rejects on timeout, the race resolves ([]when the other env is empty), and the existing empty-result path redirects to "no results found".Tests in
operatorApi.test.ts: prod-times-out + staging-empty resolves to[](the reported hang), and both-envs-time-out rejects instead of hanging.Note: the sibling env-race helpers in this file (
getOrder,getTrades, competition lookups) share the same unbounded-prod shape; happy to bound those in a follow-up if you'd like, kept this PR to the tx-search path.Summary by CodeRabbit
Bug Fixes
Tests