Repository navigation
fix(web): an idle application page reloads every minute and when its stream reopens (closes #492) - #512
Merged
Conversation
…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]>
|
Warning Review limit reachedYou'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. View limit details
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. |
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.LiveEvents.connect: it takes anopenedcallback, 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.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:openedcallback triggers a reload.The idle, reconnection and coalescing cases failed on the previous code. The web suite passes (58 files), as do
web:lintandweb: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.