[web-console] Make status polling resilient to hiding the page by Karakatiza666 · Pull Request #6079 · feldera/feldera · GitHub
Skip to content

[web-console] Make status polling resilient to hiding the page#6079

Merged
Karakatiza666 merged 1 commit intomainfrom
fix-ui-3
Apr 22, 2026
Merged

[web-console] Make status polling resilient to hiding the page#6079
Karakatiza666 merged 1 commit intomainfrom
fix-ui-3

Conversation

@Karakatiza666
Copy link
Copy Markdown
Contributor

Fix #5913

The problem was the default browser polling mechanism (setTimeout and setInterval) gets severely throttled when the page is hidden (e.g. user switches to another tab), or when it simply goes out of focus (if the action was requested on a certain timeout the browser can trigger the callback later than requested). When page was hidden for a long time a lot of polling requests got queued by the browser and then executed in quick succession when the user returned to the page; causing some requests to fail and causing toast errors and unexpected program state corruption.

The fix is two-fold:

  • Use the package worker-timers to make sure the requested timeouts used for polling logic get executed on schedule and do not get throttled by browsers in some scenarios;
  • Stop polling altogether when the browser window is hidden.

All uses of useInterval and closedIntervalAction play nicely with the changed semantics of not running the updates when the browser tab is hidden (not if it's simply out of focus)

Since they only fundamentally differ in the way they are used, useInterval() now re-uses the more generic closedIntervalAction().

Tested: manually tested some features that require polling: pipeline performance metrics updates, checked periodic health, license and config requests are being sent; tested that the page behaves normally after leaving it for a long time and coming back. Added unit tests for the closedIntervalAction primitive that validate the behavior when the browser tab is returned to, and the cadence of callbacks after it

Copy link
Copy Markdown

@mythical-fred mythical-fred left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems rather indiscriminate, it will catch all kinds of errors

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only error that could occur here is related to attempting to clear the already cleared timer, so catch-all is fine

}

export type ClosedIntervalOptions = {
/** Delay before the first invocation. Defaults to `periodMs`. */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is periodMs?
Why does this need a default?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

periodMs is a period with which a certain action is performed, it is passed as an argument to closedIntervalAction(). It is a way to have the first execution of the action be offset from the start of the loop, while keeping the same period for all the subsequent action callabcks

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is "rejection handling"?
which caller are we talking about here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Rejection handling" means catching any exceptions thrown. "Caller" is implied as whatever code that called closedIntervalAction() meaning this function, designed to only provide reliable callbacks on set interval, does not take on responsibility of handling/bubbling up exceptions that occur in the action to be repeated

@Karakatiza666 Karakatiza666 added this pull request to the merge queue Apr 20, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 21, 2026
@Karakatiza666 Karakatiza666 enabled auto-merge April 22, 2026 11:01
@Karakatiza666 Karakatiza666 added this pull request to the merge queue Apr 22, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 22, 2026
Signed-off-by: Karakatiza666 <bulakh.96@gmail.com>
@Karakatiza666 Karakatiza666 enabled auto-merge April 22, 2026 15:04
@Karakatiza666 Karakatiza666 added this pull request to the merge queue Apr 22, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Apr 22, 2026
@Karakatiza666 Karakatiza666 added this pull request to the merge queue Apr 22, 2026
Merged via the queue into main with commit 761ce59 Apr 22, 2026
1 check passed
@Karakatiza666 Karakatiza666 deleted the fix-ui-3 branch April 22, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[webconsole] After long disconnection the webconsole shows an endless stream of popups

3 participants