Skip to content

[client] Coalesce SubscribeStatus snapshot bursts - #6942

Open
pappz wants to merge 2 commits into
mainfrom
fix/subscribe-status-coalesce
Open

[client] Coalesce SubscribeStatus snapshot bursts#6942
pappz wants to merge 2 commits into
mainfrom
fix/subscribe-status-coalesce

Conversation

@pappz

@pappz pappz commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Describe your changes

SubscribeStatus sent a full status snapshot for every state change tick, so bursts (route reevaluation, peer connect and teardown, engine start and stop) produced many redundant sends of identical or nearly identical snapshots, each one serialized and rendered again by the desktop UI.

This change coalesces bursts deterministically: the first tick is sent immediately, then a 200ms window absorbs the rest and a single trailing snapshot covers whatever arrived meanwhile. Every send remains a full snapshot of the current
state, so no information is lost. In local testing a connect cycle dropped from about 15 sends to 6.

Issue ticket number and link

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)
  • This change does not modify the public API, gRPC protocols, functionality behavior, CLI / service flags, or introduce a new feature — OR I have discussed it with the NetBird team beforehand (link the issue / Slack thread in the description). See CONTRIBUTING.md.

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

https://github.com/netbirdio/docs/pull/__


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Improved status update delivery by consistently coalescing rapid bursts of changes.
    • Added a short coalescing window to send fewer, more complete updates while keeping the latest status.
    • Enhanced stream cancellation/closure handling to stop cleanly without leaving consumers waiting.

@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a7631a59-aa85-4929-bf00-8c331e89d7c6

📥 Commits

Reviewing files that changed from the base of the PR and between e1d82fc and 4c95b20.

📒 Files selected for processing (1)
  • client/server/status_stream.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • client/server/status_stream.go

📝 Walkthrough

Walkthrough

SubscribeStatus now uses a 200ms timer-based window to absorb status-update bursts and emit one trailing full snapshot when additional ticks arrive, while handling stream cancellation and tick-channel closure.

Changes

Status stream coalescing

Layer / File(s) Summary
Coalescing window contract
client/server/status_stream.go
Defines the 200ms coalescing window and documents quiet-period plus trailing-snapshot behavior.
Burst collection and snapshot emission
client/server/status_stream.go
Collects additional ticks with a timer, emits a trailing snapshot when needed, and handles channel closure or context cancellation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title concisely summarizes the main change: coalescing SubscribeStatus snapshot bursts.
Description check ✅ Passed The description covers the behavior change, rationale, checklist, and docs note, though the issue ticket field is left blank.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/subscribe-status-coalesce

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@client/server/status_stream.go`:
- Around line 75-76: Update the timer.C branch in the status-stream coalescing
loop to non-blockingly drain any already-buffered tick from ch before returning
pending, true. Preserve the existing behavior when no tick is queued and ensure
the drain does not wait for a future tick.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 90bf28dc-d4d3-43e3-bf81-08eee92cd198

📥 Commits

Reviewing files that changed from the base of the PR and between 9269b56 and e1d82fc.

📒 Files selected for processing (1)
  • client/server/status_stream.go

Comment thread client/server/status_stream.go
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Jul 28, 2026

Copy link
Copy Markdown

Release artifacts

Built for PR head 4c95b20 in workflow run #17193.

Artifact Link
All release artifacts Download
Linux packages Download
Windows packages Download
macOS packages Download
UI artifacts Download
UI macOS artifacts Download

GHCR images (amd64)

This comment is updated by the Release workflow. Artifact links expire according to the workflow retention policy.

@coderabbitai coderabbitai Bot mentioned this pull request Jul 29, 2026
8 tasks
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.

1 participant