perf(git): pause git status polling when page is hidden#600
Open
HUQIANTAO wants to merge 1 commit into
Open
Conversation
useGitStatus polls GET /api/git/status every 10s via setInterval, regardless of page visibility. Each poll spawns a git subprocess on the server side — in large repos this takes 200-500ms. Combined with the notification poll (5s), the app makes at least 1 HTTP request every 5 seconds even when the user is on a different tab or the window is minimized. Fix: stop the interval when document.visibilityState === 'hidden' and restart it (with an immediate fetch) when the page becomes visible again. The git-refresh custom event listener remains active so manual refreshes still work regardless of visibility state.
|
Someone is attempting to deploy a commit to the op7418's projects Team on Vercel. A member of the Team first needs to authorize it. |
This was referenced Jun 4, 2026
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.
Problem
useGitStatuspollsGET /api/git/statusevery 10 seconds viasetInterval, unconditionally. Each poll spawns agit statussubprocess on the server side — in large repos this takes 200–500ms. The polling continues even when:Combined with the notification poll (5s interval), the app makes at least 1 HTTP request every 5 seconds even when completely idle.
Fix
Implement visibility-aware pause/resume:
setIntervalentirely. No polls, no HTTP requests, no subprocess spawns.git-refreshcustom event listener remains active regardless of visibility state.This eliminates all background git polling when the app isn't being actively viewed, reducing both CPU (no subprocess spawns) and network overhead.