[OPIK-5479] [FE] fix: clear cached pair code on runner connection#6035
[OPIK-5479] [FE] fix: clear cached pair code on runner connection#6035
Conversation
When a runner connects, the backend immediately consumes the pairing code (Redis getAndDelete). However the frontend kept the stale code in React Query cache. If the runner later disconnected, the empty state re-displayed the expired code, causing users to attempt reconnection with a code that would always fail. Fix: use queryClient.removeQueries() to evict the pair code cache as soon as isConnected becomes true. On subsequent disconnection React Query sees no cached data and fetches a fresh code on demand.
📋 PR Linter Failed❌ Missing Section. The description is missing the ❌ Missing Section. The description is missing the |
miguelgrc
left a comment
There was a problem hiding this comment.
Thanks for taking care of it, LGTM! 🚀
|
🔄 Test environment deployment process has started Phase 1: Deploying base version You can monitor the progress here. |
Tests verify that: - Empty state shows pair code when disconnected - Connected state renders when runner is connected - Pair code cache is cleared (removeQueries) on connection - Pair code cache is NOT cleared when disconnected
|
✅ Test environment is now available! To configure additional Environment variables for your environment, run [Deploy Opik AdHoc Environment workflow] (https://github.com/comet-ml/comet-deployment/actions/workflows/deploy_opik_adhoc_env.yaml) Access Information
The deployment has completed successfully and the version has been verified. |
|
🔄 Test environment deployment process has started Phase 1: Deploying base version You can monitor the progress here. |
Details
When using
opik connect --pair <CODE>, the pairing succeeds on both sides but if the runner later disconnects under the code TTL, the FE re-displays the same (already consumed) pairing code. Since codes are single-use, reconnection always fails with "Invalid or expired pairing code".Root cause: The backend deletes the pairing code from Redis on connection (
getAndDelete), but the frontend keeps it in React Query cache. On a quick disconnection, the empty state renders with the stale cached code.Fix: Call
queryClient.removeQueries()to evict the pair code cache as soon asisConnectedbecomes true. When the runner later disconnects, React Query sees no cached data and fetches a fresh code on demand — no wasted TTL ticking while connected.Change checklist
Issues
AI-WATERMARK
AI-WATERMARK: yes
Testing
npm run build)opik connect --pair, verify pair code is evicted from cache on connection, verify fresh code is fetched on disconnectionDocumentation
N/A