Skip to content

fix(android): check pending notification before WebSocket connection guard#7048

Open
deepak0x wants to merge 1 commit intoRocketChat:developfrom
deepak0x:fix/onauthchange-memory-leak
Open

fix(android): check pending notification before WebSocket connection guard#7048
deepak0x wants to merge 1 commit intoRocketChat:developfrom
deepak0x:fix/onauthchange-memory-leak

Conversation

@deepak0x
Copy link
Contributor

@deepak0x deepak0x commented Mar 11, 2026

Proposed changes

On Android, when a user taps a push notification while the WebSocket is reconnecting, the app opens but does not navigate to the room. The notification tap is silently ignored.

Root cause: checkPendingNotification() in app/sagas/state.js was called inside the isAuthAndConnected() guard, which requires meteor.connected === true. During WebSocket reconnection, this returns false, so the function is never reached and the pending notification data in SharedPreferences is never processed.

Fix: Move checkPendingNotification() before the isAuthAndConnected() guard. This is safe because:

  • checkPendingNotification() dispatches a deepLinkingOpen Redux action
  • The deepLinking saga already has its own yield take(LOGIN.SUCCESS) mechanism to wait for reconnection before navigating
  • No notification data is lost or duplicated — the native module clears SharedPreferences after reading

This is a minimal, targeted fix that leverages the existing reconnection-wait pattern used throughout the codebase.

Issue(s)

Fixes #7013

How to test or reproduce

  1. Open the app and log into a server
  2. Background the app
  3. Send a message from another user/device to trigger a push notification
  4. Enable airplane mode briefly to force WebSocket disconnect
  5. Tap the notification
  6. Before fix: App opens but stays on the last screen — no navigation
  7. After fix: App opens and navigates to the correct room once connection re-establishes

Types of changes

  • Bugfix (non-breaking change which fixes an issue)

Checklist

  • I have read the CONTRIBUTING doc
  • I have signed the CLA
  • Lint and unit tests pass locally with my changes

Further comments

The deepLinking.js saga (which handles deepLinkingOpen actions) already correctly waits for LOGIN.SUCCESS before navigating to a room (see lines 172-178). By calling checkPendingNotification() before the connection guard, we ensure notification data is read from SharedPreferences and dispatched to the deep linking saga, which handles the reconnection wait.

Summary by CodeRabbit

  • Refactor
    • Optimized notification handling by adjusting the sequence of operations during app startup to check for pending notifications earlier, improving overall reliability.

…guard

When tapping a push notification while WebSocket is reconnecting, the
app opens but does not navigate to the room. This happens because
checkPendingNotification() was gated behind isAuthAndConnected(), which
requires meteor.connected === true. During reconnection, this check
returns false and the notification tap is silently ignored.

Fix: Move checkPendingNotification() before the connection guard. This
is safe because it dispatches deepLinkingOpen, and the deepLinking saga
already waits for LOGIN.SUCCESS before navigating to the room.

Fixes RocketChat#7013
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 11, 2026

Caution

Review failed

The head commit changed during the review from eb2683a to ff38eb0.

Walkthrough

A bug fix that reorders the notification check in the foreground handler to execute before connection verification, enabling Android push notifications to be processed even when the WebSocket is still reconnecting.

Changes

Cohort / File(s) Summary
Notification Check Reordering
app/sagas/state.js
Moved checkPendingNotification() call to execute before isAuthAndConnected() guard with independent error handling, and removed the duplicate invocation that occurred after checkAndReopen(). This ensures pending notifications are processed regardless of current WebSocket connection state on app foreground.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested labels

type: bug

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(android): check pending notification before WebSocket connection guard' directly describes the main change: moving the checkPendingNotification() call before the isAuthAndConnected() guard, which is the core fix.
Linked Issues check ✅ Passed The PR directly addresses all objectives from issue #7013: ensuring notification taps trigger navigation even during WebSocket reconnection by calling checkPendingNotification() before the isAuthAndConnected() guard.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the notification handling bug; only the notification check sequence was modified without introducing unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

@deepak0x deepak0x force-pushed the fix/onauthchange-memory-leak branch from eb2683a to ff38eb0 Compare March 11, 2026 23:28
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.

bug: [Android] Push notification tap ignored when WebSocket is reconnecting on app foreground

1 participant