FAROS icon indicating copy to clipboard operation
FAROS copied to clipboard

CodeSession polling interval captures stale session status

Open cwalker64 opened this issue 3 months ago • 0 comments

CodeSession polling interval captures stale session status

Severity: Medium File: frontend/src/pages/Code/CodeSession.tsx:59

The useEffect hook sets up a 3-second polling interval that checks session?.status. However, the closure captures the session value at the time the effect runs. When loadData() updates session, the interval continues using the old status until the effect re-runs.

useEffect(() => {
  loadData()
  const interval = setInterval(() => {
    if (session?.status === 'running' || session?.status === 'pending') {
      loadData()
    }
  }, 3000)
  return () => clearInterval(interval)
}, [loadData, session?.status])

Why it matters

When a session transitions from "running" to "completed", the polling may continue for several cycles before the effect cleanup runs, causing unnecessary API calls and potential UI flicker.

cwalker64 avatar Aug 30 '26 20:08 cwalker64