fix(bridge): keep bridge order status polling while tab is hidden#7707
fix(bridge): keep bridge order status polling while tab is hidden#7707tenderdeve wants to merge 6 commits into
Conversation
SWR config for the cross-chain order hook disabled background refresh (`refreshWhenHidden: false`). As a result, a swap-and-bridge order would stay marked as pending on CoW Swap (and on Explorer) until the tab was focused again, lagging the actual bridge status by 4-5s on each return. Enable `refreshWhenHidden: true` for both the cowswap-frontend and explorer cross-chain order hooks so the bridge status (and the order state derived from it) stays in sync even when the tab is in the background. Polling still stops once the bridge reaches a final status. Closes cowprotocol#6694
|
@tenderdeve is attempting to deploy a commit to the cow-dev Team on Vercel. A member of the Team first needs to authorize it. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughTwo ChangesBackground refresh for cross-chain order status
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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-7707 Source fork branch:
|
…orders-background-updates
elena-zh
left a comment
There was a problem hiding this comment.
LGTM from the UI perspective
alfetopito
left a comment
There was a problem hiding this comment.
This addresses the issue, yes, however, we have the policy everywhere in this project to not refresh when hidden https://github.com/search?q=repo%3Acowprotocol%2Fcowswap%20refreshWhenHidden&type=code
How about using revalidateOnFocus instead, to trigger the check when the tab is focused again?
But I'd be willing to accept the change if this is the same behaviour as the order execution.
On a quick look I did not find the config for that, so your change could be the correct one.
|
@alfetopito the order execution doesn't go through SWR. It polls with plain The bridge hook is the only SWR-based one, and |
fairlighteth
left a comment
There was a problem hiding this comment.
✅ AI Review (Codex GPT-5, worked 37m): no new non-duplicate findings
Review completed. I found no new non-duplicate comments worth posting.
Related context checked
refreshWhenHiddenpolicy concern is already covered by the existing top-level review comment; I rechecked the author’s reply againstPendingOrdersUpdater, which does poll regular orders viasetInterval.- Both changed hooks still stop polling once bridge status reaches
EXECUTED,EXPIRED, orREFUND. - Current PR checks have preview/deploy checks passing; lint/typecheck/test jobs are skipped on this run.
Generated using the pr-review skill from the CoW Protocol skills repo.
Closes #6694.
The SWR config for the cross-chain order hook had
refreshWhenHidden: false, so once the tab lost focus the bridge status stopped being polled. When the tab was re-opened, the order would stay marked as pending on CoW Swap (and lag on Explorer) for the usual 4-5s window before SWR caught up.Flip
refreshWhenHidden: trueon both the cowswap-frontend and explorer cross-chain order hooks so the status keeps updating in the background. Polling still stops as soon as the bridge reaches a final status (EXECUTED/EXPIRED/REFUND), so there's no extra traffic for completed orders.Files
apps/cowswap-frontend/src/entities/bridgeOrders/hooks/useCrossChainOrder.tsapps/explorer/src/modules/bridge/hooks/useCrossChainOrder.tsTesting steps
Summary by CodeRabbit