Skip to content

perf(notifications): respect server-recommended poll interval - #3116

Merged
setchy merged 1 commit into
mainfrom
feat/respect-x-poll-interval
Jul 29, 2026
Merged

perf(notifications): respect server-recommended poll interval#3116
setchy merged 1 commit into
mainfrom
feat/respect-x-poll-interval

Conversation

@afonsojramos

@afonsojramos afonsojramos commented Jul 29, 2026

Copy link
Copy Markdown
Member

Fixes part of #3101

Problem

Polling uses only the user-configured fetchInterval and ignores the X-Poll-Interval header GitHub returns on the notifications list endpoint. The header advertises the minimum poll spacing the server currently wants (normally 60, raised when GitHub asks clients to back off), so Gitify keeps polling at the configured rate even when the server requests slower polling.

Change

  • New pollInterval registry (src/renderer/utils/notifications/pollInterval.ts): forge clients report the latest server-recommended interval per account, and computeRefetchIntervalMs returns the user interval stretched to the slowest recommendation across the currently polled accounts.
  • The GitHub client reports X-Poll-Interval from both the single-page and paginated notifications list fetches.
  • useNotifications passes refetchInterval as a function, so TanStack Query re-evaluates the interval after every fetch and picks up server changes without a query-key change.

Forges that do not send the header never report, and polling falls back to the user interval unchanged. With the default 60s fetch interval and GitHub's normal X-Poll-Interval: 60 this is behavior-neutral; polling only slows when GitHub asks for more spacing (or when a user configures an interval below the server minimum).

Tests

  • pollInterval.test.ts: stretch-to-slowest semantics, never faster than the user interval, ignoring intervals from accounts no longer polled, ignoring invalid values.
  • client.test.ts: header capture on both the single-page and paginated fetch paths.

@sonarqubecloud

Copy link
Copy Markdown

Comment thread src/renderer/utils/notifications/pollInterval.ts
@setchy
setchy self-requested a review July 29, 2026 16:45
@setchy
setchy merged commit ea302a5 into main Jul 29, 2026
18 checks passed
@setchy
setchy deleted the feat/respect-x-poll-interval branch July 29, 2026 21:11
@github-actions github-actions Bot added this to the Release 7.x.x milestone Jul 29, 2026
This was referenced Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor Refactoring of existing feature

Development

Successfully merging this pull request may close these issues.

2 participants