Skip to content

fix: restore environment polling after #7284 regression#7313

Closed
talissoncosta wants to merge 1 commit intomainfrom
fix/environment-ready-checker-polling-regression
Closed

fix: restore environment polling after #7284 regression#7313
talissoncosta wants to merge 1 commit intomainfrom
fix/environment-ready-checker-polling-regression

Conversation

@talissoncosta
Copy link
Copy Markdown
Contributor

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Follow-up to #7284.

Bug

Environments that come back with is_creating: true from the API got stuck on the "Preparing your environment" loader indefinitely. A full page reload was the only way to recover.

Root cause

EnvironmentReadyChecker.tsx passed pollingInterval: data?.is_creating ? POLL_INTERVAL_MS : 0 to useGetEnvironmentQuery, where data is the same hook's destructured result. At the time the options object is evaluated, data is unassigned, so the reference silently resolved to undefined and pollingInterval was always 0. Polling never started.

For envs returning is_creating: false on the first fetch (the common case), the component rendered children immediately and the bug was invisible. For envs still in the creating state on the backend, polling never re-fetched, so the UI never detected the transition to ready.

Fix

Gate pollingInterval on a pollingStopped state flag updated by a useEffect after the hook returns. The flag resets when the URL environment changes so polling restarts for newly-visited envs, and flips to true once the env is known-ready or known-bad (error / different project).

How did you test this code?

Manual:

  1. Ran the app locally against staging.
  2. Temporarily patched the component to force data = { ...rawData, is_creating: true } in the render path so the "Preparing your environment" loader was always displayed.
  3. Opened DevTools Network tab, filtered to environments/, navigated to an environment's Features page, and left it for ~1 minute.
  4. Before fix: captured HAR showed a single request to /api/v1/environments/{key}/ followed by ~100 seconds of silence — no polling.
  5. After fix: a new request to /api/v1/environments/{key}/ fires every ~1 second while is_creating: true. Polling stops cleanly once the response shows is_creating: false, on error, or if the env belongs to a different project. Switching to a different environment resets the flag and restarts polling.

No new unit tests: the frontend's Jest config is Node-only (no jsdom) and there is no existing React component test infrastructure. Worth following up with a dedicated component-test harness PR to guard against this class of regression in the future.

🤖 Generated with Claude Code

EnvironmentReadyChecker.tsx passed `pollingInterval: data?.is_creating ? POLL_INTERVAL_MS : 0`
to useGetEnvironmentQuery, where `data` was the same hook's destructured result. At the
time the options object is evaluated, `data` is unassigned, so the reference silently
resolved to `undefined` and `pollingInterval` was always `0`. Envs returned with
`is_creating: false` on first fetch rendered children and hid the bug; envs still in the
creating state on the backend showed "Preparing your environment" indefinitely until a
full page reload.

Gate pollingInterval on a `pollingStopped` state flag updated by a useEffect after the
hook returns. Resets on environment ID change so polling restarts for newly-visited envs.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview, Comment Apr 22, 2026 0:58am
flagsmith-frontend-staging Ready Ready Preview, Comment Apr 22, 2026 0:58am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Apr 22, 2026 0:58am

Request Review

@github-actions github-actions Bot added front-end Issue related to the React Front End Dashboard fix labels Apr 22, 2026
@Zaimwa9 Zaimwa9 closed this Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants