Skip to content

CodeSession polling interval captures stale session status #162

Description

@cwalker64

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions