Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/sagas/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ const appHasComeBackToForeground = function* appHasComeBackToForeground() {
if (appRoot !== RootEnum.ROOT_INSIDE) {
return;
}
const isReady = yield isAuthAndConnected();
if (!isReady) {
const login = yield select(state => state.login);
if (!login.isAuthenticated) {
return;
}
try {
const server = yield select(state => state.server.server);
yield localAuthenticate(server);
// Always reconnect on foreground; gating on meteor.connected would skip
// the call precisely when the socket died silently in background.
checkAndReopen();
// Check for pending notification when app comes to foreground (Android - notification tap while in background)
checkPendingNotification().catch(e => {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"use-deep-compare-effect": "1.6.1",
"xregexp": "5.0.2",
"yup": "0.32.11",
"zustand": "^5.0.10"
"zustand": "5.0.10"
},
"resolutions": {
"ua-parser-js": "1.0.2",
Expand Down
46 changes: 45 additions & 1 deletion patches/@rocket.chat+sdk+1.3.3-mobile.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,51 @@ diff --git a/node_modules/@rocket.chat/sdk/lib/drivers/ddp.ts b/node_modules/@ro
index 19d31ae..d5295b5 100644
--- a/node_modules/@rocket.chat/sdk/lib/drivers/ddp.ts
+++ b/node_modules/@rocket.chat/sdk/lib/drivers/ddp.ts
@@ -549,7 +549,9 @@ export class DDPDriver extends EventEmitter implements ISocket, IDriver {
@@ -175,15 +175,36 @@
return Promise.resolve()
}

- // Call open directly, so it skips openTimeout
+ // Tear down any existing socket and reopen unconditionally. The `connected`
+ // getter trusts `readyState === 1 && alive()` — both can lie after iOS
+ // background suspend (zombie WebSocket still reporting OPEN, lastPing still
+ // inside the alive window because of a server message just before suspend).
+ // Forcing teardown + resetting lastPing guarantees a fresh connection.
checkAndReopen = () => {
- if (!this.connected) {
- if (this.openTimeout) {
- clearTimeout(this.openTimeout as any)
- delete this.openTimeout
- }
- this.open()
+ this.lastPing = 0
+ if (this.openTimeout) {
+ clearTimeout(this.openTimeout as any)
+ delete this.openTimeout
}
+ if (this.pingTimeout) {
+ clearTimeout(this.pingTimeout as any)
+ delete this.pingTimeout
+ }
+ if (this.connection) {
+ try {
+ // Detach handlers before close so the orphaned socket can't trigger
+ // another reopen() race against the open() we're about to start.
+ this.connection.onopen = null as any
+ this.connection.onmessage = null as any
+ this.connection.onerror = null as any
+ this.connection.onclose = null as any
+ this.connection.close(userDisconnectCloseCode)
+ } catch (e) {
+ this.logger.debug(`[ddp] checkAndReopen close error: ${(e as Error).message}`)
+ }
+ this.connection = undefined
+ }
+ this.open()
}

/** Clear connection and try to connect again. */
@@ -549,7 +570,9 @@
'uiInteraction',
'e2ekeyRequest',
'userData',
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13841,7 +13841,7 @@ yup@0.32.11:
resolved "https://registry.yarnpkg.com/zod/-/zod-4.3.6.tgz#89c56e0aa7d2b05107d894412227087885ab112a"
integrity sha512-rftlrkhHZOcjDwkGlnUtZZkvaPHCsDATp4pGpuOOMDaTdDDXF91wuVDJoWoPsKX/3YPQ5fHuF3STjcYyKr+Qhg==

zustand@^5.0.10:
version "5.0.12"
resolved "https://registry.yarnpkg.com/zustand/-/zustand-5.0.12.tgz#ed36f647aa89965c4019b671dfc23ef6c6e3af8c"
integrity sha512-i77ae3aZq4dhMlRhJVCYgMLKuSiZAaUPAct2AksxQ+gOtimhGMdXljRT21P5BNpeT4kXlLIckvkPM029OljD7g==
zustand@5.0.10:
version "5.0.10"
resolved "https://registry.yarnpkg.com/zustand/-/zustand-5.0.10.tgz#4db510c0c4c25a5f1ae43227b307ddf1641a3210"
integrity sha512-U1AiltS1O9hSy3rul+Ub82ut2fqIAefiSuwECWt6jlMVUGejvf+5omLcRBSzqbRagSM3hQZbtzdeRc6QVScXTg==
Loading