Skip to content

Commit

Permalink
Merge pull request #57680 from Expensify/revert-57255-tgolen-pingpong…
Browse files Browse the repository at this point in the history
…-triggeroffline

[CP Staging] Revert "[No QA] Change offline status when Pusher PINGPONG fails"

(cherry picked from commit 0b5045d)

(CP triggered by puneetlath)
  • Loading branch information
MarioExpensify authored and OSBotify committed Mar 3, 2025
1 parent 2e0dfda commit 122a23a
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions src/libs/actions/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import Log from '@libs/Log';
import Navigation from '@libs/Navigation/Navigation';
import {isOffline} from '@libs/Network/NetworkStore';
import * as SequentialQueue from '@libs/Network/SequentialQueue';
import NetworkConnection from '@libs/NetworkConnection';
import * as NumberUtils from '@libs/NumberUtils';
import * as PersonalDetailsUtils from '@libs/PersonalDetailsUtils';
import Pusher from '@libs/Pusher';
Expand Down Expand Up @@ -916,7 +915,6 @@ function subscribeToPusherPong() {

// When any PONG event comes in, reset this flag so that checkforLatePongReplies will resume looking for missed PONGs
pongHasBeenMissed = false;
NetworkConnection.setOfflineStatus(false, 'PONG event was recieved from the server so assuming that means the client is back online');
});
}

Expand All @@ -940,9 +938,6 @@ function pingPusher() {
const pingID = NumberUtils.rand64();
const pingTimestamp = Date.now();

// Reset this flag so that checkforLatePongReplies will resume looking for missed PONGs (in the case we are coming back online after being offline for a bit)
pongHasBeenMissed = false;

// In local development, there can end up being multiple intervals running because when JS code is replaced with hot module replacement, the old interval is not cleared
// and keeps running. This little bit of logic will attempt to keep multiple pings from happening.
if (pingTimestamp - lastPingSentTimestamp < PING_INTERVAL_LENGTH_IN_SECONDS * 1000) {
Expand Down Expand Up @@ -977,7 +972,6 @@ function checkforLatePongReplies() {
// When going offline, reset the pingpong state so that when the network reconnects, the client will start fresh
lastPingSentTimestamp = Date.now();
pongHasBeenMissed = true;
NetworkConnection.setOfflineStatus(true, 'PONG event was not received from the server in time so assuming that means the client is offline');
} else {
Log.info(`[Pusher PINGPONG] Last PONG event was ${timeSinceLastPongReceived} ms ago so not going offline`);
}
Expand All @@ -986,11 +980,6 @@ function checkforLatePongReplies() {
let pingPusherIntervalID: ReturnType<typeof setInterval>;
let checkforLatePongRepliesIntervalID: ReturnType<typeof setInterval>;
function initializePusherPingPong() {
// Skip doing the ping pong during tests so that the network isn't knocked offline, forcing tests to timeout
if (process.env.NODE_ENV === 'test') {
return;
}

// Only run the ping pong from the leader client
if (!ActiveClientManager.isClientTheLeader()) {
Log.info("[Pusher PINGPONG] Not starting PING PONG because this instance isn't the leader client");
Expand Down

0 comments on commit 122a23a

Please sign in to comment.