Skip to content

regression: restore reactive ConnectionStatusBar updates during reconnection#40616

Merged
ggazzo merged 1 commit into
developfrom
fix/connection-status-reactivity
May 19, 2026
Merged

regression: restore reactive ConnectionStatusBar updates during reconnection#40616
ggazzo merged 1 commit into
developfrom
fix/connection-status-reactivity

Conversation

@ggazzo
Copy link
Copy Markdown
Member

@ggazzo ggazzo commented May 19, 2026

Summary

  • ServerProvider now drives its status snapshot off Meteor.status's Tracker reactivity (via meteorBackedSdk.onMeteorStatusChange) instead of Meteor.connection._stream reset/disconnect events. Stream events only fire when the socket itself reconnects or drops, so internal connectingwaiting cycles and per-second retryTime ticks were silently dropped — ConnectionStatusBar stayed pinned on a stale status (or never appeared) while a reconnection ran.
  • subscribeStatus recomputes the snapshot immediately after wiring the bridge so the value useSyncExternalStore returns on first mount can't stay stuck on whatever cachedStatus was at module load, closing the race when the socket connected before <ServerProvider> mounted.

Regression from #40482.

Test plan

  • Boot the app with DevTools open, throttle network or hit the WS endpoint with a temporary block, and observe ConnectionStatusBar cycling through connectingwaitingconnecting with the countdown ticking down each second instead of freezing.
  • Pause the WS server, let the bar reach waiting, resume the server, and confirm the bar disappears as soon as Meteor's status flips back to connected (no manual page refresh needed).
  • Hard reload while the dev server is offline: bar should render with the current status on mount instead of staying on whatever was captured at module evaluation.
  • Re-run with SDK_TRANSPORT_ENABLED=true to confirm the SDK-transport branch still behaves the same.

https://rocketchat.atlassian.net/browse/CORE-2203

Summary by CodeRabbit

  • Bug Fixes
    • Improved connection status synchronization to prevent stale status data on initialization, ensuring accurate server connectivity information is displayed immediately when the app loads.

Review Change Stack

…atusBar

Drive ServerProvider's status snapshot off Meteor.status's Tracker
reactivity instead of `_stream` `reset`/`disconnect` events. The stream
only fires when the socket itself reconnects or drops, so internal
status transitions (`connecting` <-> `waiting`) and per-second
`retryTime` ticks left ConnectionStatusBar pinned on a stale status
during reconnection.

`subscribeStatus` also recomputes the snapshot immediately after wiring
the bridge so the value picked up by `useSyncExternalStore` doesn't
remain stuck on whatever `cachedStatus` held at module load, closing the
race when the socket connected before `<ServerProvider>` mounted.

Regression from #40482.
@ggazzo ggazzo requested a review from a team as a code owner May 19, 2026 19:56
@ggazzo ggazzo added this to the 8.5.0 milestone May 19, 2026
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 19, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 19, 2026

⚠️ No Changeset found

Latest commit: 118ac14

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 19, 2026

Walkthrough

Meteor connection status bridging is refactored from direct stream event listening to reactive Tracker.autorun on Meteor.status() updates. The initial snapshot race where cached status could be stale is closed by synchronously recalculating and updating status when listeners subscribe.

Changes

Connection Status Bridging Race Fix

Layer / File(s) Summary
Meteor status bridge via Tracker reactivity
apps/meteor/client/lib/sdk/meteorBackedSdk.ts
onMeteorStatusChange is refactored to use Tracker.autorun driven by Meteor.status() reactivity instead of listening to Meteor.connection._stream lifecycle events. Adds Tracker import, environment guards for missing Meteor.status/Tracker.autorun, a firstRun skip to prevent immediate callback firing, try/catch wrapping, and cleanup via computation.stop().
Initial status snapshot synchronization
apps/meteor/client/providers/ServerProvider.tsx
subscribeStatus now synchronously computes the latest connection status when a listener subscribes, updates the cached status if it differs, and immediately invokes the listener to close the race window and ensure correct initial useSyncExternalStore snapshot.

Possibly related PRs

Suggested labels

type: bug

Suggested reviewers

  • tassoevan

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'regression: restore reactive ConnectionStatusBar updates during reconnection' accurately summarizes the main change: restoring reactive status updates for the ConnectionStatusBar during reconnection by switching from stream-based to Tracker-based reactivity.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@ggazzo ggazzo changed the title fix(client): restore reactive ConnectionStatusBar updates during reconnection regression: restore reactive ConnectionStatusBar updates during reconnection May 19, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.67%. Comparing base (a44b12e) to head (118ac14).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #40616      +/-   ##
===========================================
+ Coverage    69.63%   69.67%   +0.03%     
===========================================
  Files         3323     3323              
  Lines       122762   122752      -10     
  Branches     21898    21899       +1     
===========================================
+ Hits         85481    85522      +41     
+ Misses       33915    33881      -34     
+ Partials      3366     3349      -17     
Flag Coverage Δ
e2e 59.30% <66.66%> (+0.10%) ⬆️
e2e-api 47.05% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ggazzo ggazzo merged commit d36f48b into develop May 19, 2026
45 of 47 checks passed
@ggazzo ggazzo deleted the fix/connection-status-reactivity branch May 19, 2026 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants