Repository navigation
💥 Stop polling multi-channel queries every second by default - #780
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the change removing automatic polling from multi-channel query subscriptions.
No open issues 🎉
What changed in this PR
This PR removes automatic one-second database polling for multi-channel query subscriptions, reducing unnecessary database load. This is a breaking default change; explicitly configured polling intervals and the existing debounce behavior remain unchanged.
Changes:
- Default
pollIntervalto zero regardless of channel count. - Add a regression test for timer-free subscriptions and remove redundant interval overrides.
- Document polling defaults and when an explicit interval is useful.
| File | Description |
|---|---|
test/client/query-subscribe.js |
Adds timer-polling regression coverage and removes redundant overrides. |
lib/query-emitter.js |
Removes the multi-channel polling interval default. |
lib/backend.js |
Documents the purpose of pollInterval. |
docs/middleware/actions.md |
Clarifies interval and debounce defaults. |
Review effort: Balanced
At the moment, a subscribed query with more than one channel [defaults][1] `pollInterval` to 1000, so it re-runs against the database every second for as long as it's subscribed, even when nothing has changed. At Reedsy, that was ~2/3 of all our ShareDB requests. Nothing asks for that interval. It arrived with multi-channel queries in #587, where review only suggested a `pollDebounce` default to [batch polls][2]. The interval catches changes that don't publish an op on any of the query's channels, which depends on how an app picks its channels, not how many there are, and a query on one channel has never had it. This is a **BREAKING CHANGE**, though apps that already set `pollInterval` are unaffected. The `pollDebounce` default is unchanged, and this middleware, registered after the one that sets `context.channels`, restores the old interval: ```js backend.use('query', (context, next) => { if (context.channels.length > 1) context.options.pollInterval = 1000 next() }) ``` [1]: https://github.com/share/sharedb/blob/628de990e858439c1f3dbff4f65f95ef9a70d0a2/lib/query-emitter.js#L24-L31 [2]: #587 (comment) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
alecgibson
force-pushed
the
no-multi-channel-poll-interval
branch
from
November 11, 2026 16:05
8e9f692 to
1a19691
Compare
alecgibson
marked this pull request as ready for review
November 11, 2026 16:14
This was referenced Nov 11, 2026
dawidreedsy
approved these changes
Nov 12, 2026
dawidreedsy
left a comment
Contributor
There was a problem hiding this comment.
I really do not remember why did the polling 1000, but it seems fine without it.
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.
At the moment, a subscribed query with more than one channel defaults
pollIntervalto 1000, so it re-runs against the database every second for as long as it's subscribed, even when nothing has changed. At Reedsy, that was ~2/3 of all our ShareDB requests.Nothing asks for that interval. It arrived with multi-channel queries in #587, where review only suggested a
pollDebouncedefault to batch polls. The interval catches changes that don't publish an op on any of the query's channels, which depends on how an app picks its channels, not how many there are, and a query on one channel has never had it.This is a BREAKING CHANGE, though apps that already set
pollIntervalare unaffected. ThepollDebouncedefault is unchanged, and this middleware, registered after the one that setscontext.channels, restores the old interval:🤖 Generated with Claude Code
Co-Authored-By: Claude noreply@anthropic.com