Skip to content

fix(web): an idle application page reloads every minute and when its stream reopens (closes #492) - #512

Merged
samuelmbabhazi merged 4 commits into
mainfrom
fix/492-idle-page-refresh
Nov 26, 2026
Merged

samuelmbabhazi merged 4 commits into
mainfrom
fix/492-idle-page-refresh

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

What changed

  • ApplicationPage.refresh: it always schedules the next reload. That is every 3 s while a deployment runs without the event stream, or 15 s with it, as before, and every minute when nothing runs.
    • Only one reload runs at a time. Calls made meanwhile ask for exactly one more, right after.
    • Once the page is destroyed, no timer is set again.
  • LiveEvents.connect: it takes an opened callback, run on each opening of the stream, reconnections included. The application page reloads then, because a hint missed while the stream was down is not replayed.
  • SPEC 8: the page's polling is spelled out under the fallback rule.

Why

Closes #492. The page polled only while it knew of a running deployment. SPEC 8 requires a slow fallback, because an event can commit after a later one the stream already sent. An idle page that missed a hint, for example a deployment started elsewhere, stayed stale until a manual reload, and a reconnected stream reloaded nothing.

How it was tested

In application-page.spec.ts, with fake timers, on the real page with fake APIs:

  • Idle: one load, nothing at 59 s, a reload at 61 s.
  • Reconnection: the stream's opened callback triggers a reload.
  • Running deployment without the stream: a reload after 3 s.
  • Coalescing: three reconnections during a slow reload make exactly one more reload.
  • Destroyed page: nothing in the next 5 minutes.

The idle, reconnection and coalescing cases failed on the previous code. The web suite passes (58 files), as do web:lint and web:typecheck.

Security considerations

None. The page reads the same API more often when idle (once a minute), and the SSE server's permission checks and backpressure are unchanged.

…stream reopens (closes #492)

The page polled only while a deployment ran, so a change hint missed by the stream left an idle page stale until a manual reload, and a stream that reconnected reloaded nothing. It now reloads every minute when nothing runs, on each opening of the stream, one reload at a time, and stops once the page is gone.

Signed-off-by: samuel mbabhazi <[email protected]>
@samuelmbabhazi samuelmbabhazi added bug Something isn't working track:web labels Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between f777e27 and dd09790.

Files selected for processing: 4

  • apps/web/src/app/delivery/application-page.spec.ts
  • apps/web/src/app/delivery/application-page.ts
  • apps/web/src/app/delivery/live-events.ts
  • docs/SPEC.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

samuelmbabhazi added a commit that referenced this pull request Nov 26, 2026
## What changed

The browser fixture gives the API a throttle that lets the `api` attempt
through, the read quota of 300 requests a minute per account and 600 per
network. Every other limit applies as in production: login,
registration, mail, MFA and token proofs.

- `BrowserSuiteThrottle` (in `src/testing/`) extends
`PrismaIdentityThrottle`. It answers `api` with an allowed decision and
passes every other attempt to the real store.
- `integrationApp` accepts a provider override by class (`{ token,
useClass }`), next to the existing override by value, so Nest builds the
throttle with its dependencies.
- `browserApp` puts that override first, and a test's own overrides
still come after it.

## Why

`tenant.browser.spec.ts › creates scoped tokens the API accepts, and
revokes a project token` failed intermittently:

- in CI on main at `b425efe`;
- twice in a row on #512, which does not touch that page;
- locally, once in three runs and once in four.

Each failure was a different 15-second wait: the *Create API token*
button, `#token-project` and `#token-organization`.

I logged every API request and every 429 of the file:

- **What is refused.** The failing run got a 429 on `GET
/api/v1/organizations`. The token form's organization list stayed empty,
and Playwright waited for an option that never came. Passing runs got
their 429s on requests the page retries.
- **Why.** Each step of the test reloads the whole application with
`goto`, and each load reads about ten resources. The owner's page made
409 requests in its busiest minute, against a quota of 300 per account.
All pages together made 576 from `127.0.0.1`, plus the test's own
`context.request` calls, against 600 per network.

The browser suite checks screens, not the quota, and a person cannot
click at that rate. The quota keeps its own integration tests
(`identity-throttle.integration.spec.ts`,
`api-token-authentication.integration.spec.ts`). The only 429 a browser
test checks, in `security.browser.spec.ts`, is simulated by intercepting
the response in the browser, and is unaffected.

## How it was tested

- `tenant.browser.spec.ts`, four runs in a row: 13/13 each time. Before
the change, the same command failed one run in three, then one in four.
- The whole browser suite: 28/28.
- `api:typecheck` and `api:lint` pass.

## Security considerations

Test code only: the production throttle and its policy are unchanged.
Credential limits still apply in the browser suite.

Signed-off-by: samuel mbabhazi <[email protected]>
@samuelmbabhazi
samuelmbabhazi merged commit 83a2d76 into main Nov 26, 2026
27 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the fix/492-idle-page-refresh branch November 26, 2026 13:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working track:web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep a bounded fallback refresh for idle application pages

1 participant