Page MenuHomePhabricator

D12369.diff
No OneTemporary

D12369.diff

diff --git a/lib/socket/socket.react.js b/lib/socket/socket.react.js
--- a/lib/socket/socket.react.js
+++ b/lib/socket/socket.react.js
@@ -15,6 +15,7 @@
import SocketMessageUserInfosHandler from './user-infos-handler.react.js';
import { updateActivityActionTypes } from '../actions/activity-actions.js';
import { updateLastCommunicatedPlatformDetailsActionType } from '../actions/device-actions.js';
+import { fetchPendingUpdatesActionTypes } from '../actions/update-actions.js';
import {
setNewSessionActionType,
updateConnectionStatusActionType,
@@ -47,6 +48,7 @@
type SessionState,
type SessionIdentification,
type PreRequestUserState,
+ type FetchPendingUpdatesInput,
} from '../types/session-types.js';
import {
clientSocketMessageTypes,
@@ -69,6 +71,7 @@
type ActivityUpdateResponseServerSocketMessage,
type ClientStateSyncServerSocketMessage,
type PongServerSocketMessage,
+ type ClientStateSyncSocketResult,
} from '../types/socket-types.js';
import { actionLogger } from '../utils/action-logger.js';
import { getConfig } from '../utils/config.js';
@@ -108,6 +111,8 @@
+dispatch: Dispatch,
+dispatchActionPromise: DispatchActionPromise,
+showSocketCrashLoopAlert?: () => mixed,
+ +fetchPendingUpdates: FetchPendingUpdatesInput => Promise<ClientStateSyncSocketResult>,
+ +isConnectedToInternet: boolean,
};
type State = {
+inflightRequests: ?InflightRequests,
@@ -124,6 +129,8 @@
reopenConnectionAfterClosing: boolean = false;
initializedWithUserState: ?PreRequestUserState;
initFailureCountAfterPolicyAcknowledgment: number = 0;
+ initFailureCount: number = 0;
+ fetchingPendingUpdates: boolean = false;
openSocket(newStatus: ConnectionStatus) {
if (
@@ -437,6 +444,7 @@
return;
}
this.initFailureCountAfterPolicyAcknowledgment = 0;
+ this.initFailureCount = 0;
const { inflightRequests } = this.state;
if (!inflightRequests) {
@@ -678,11 +686,18 @@
} catch (e) {
if (this.props.noDataAfterPolicyAcknowledgment) {
this.initFailureCountAfterPolicyAcknowledgment++;
+ this.initFailureCount = 0;
} else {
this.initFailureCountAfterPolicyAcknowledgment = 0;
+ if (this.props.isConnectedToInternet) {
+ this.initFailureCount++;
+ } else {
+ this.initFailureCount = 0;
+ }
}
if (this.initFailureCountAfterPolicyAcknowledgment >= 2) {
this.initFailureCountAfterPolicyAcknowledgment = 0;
+ this.initFailureCount = 0;
this.props.showSocketCrashLoopAlert?.();
this.props.dispatch({
type: setActiveSessionRecoveryActionType,
@@ -693,6 +708,22 @@
},
});
return;
+ } else if (this.initFailureCount >= 2 && !this.fetchingPendingUpdates) {
+ this.initFailureCountAfterPolicyAcknowledgment = 0;
+ this.initFailureCount = 0;
+ this.fetchingPendingUpdates = true;
+ try {
+ const sessionState = this.props.sessionStateFunc();
+ void this.props.dispatchActionPromise(
+ fetchPendingUpdatesActionTypes,
+ this.props.fetchPendingUpdates({
+ ...sessionState,
+ keyserverID: this.props.keyserverID,
+ }),
+ );
+ } finally {
+ this.fetchingPendingUpdates = false;
+ }
}
console.log(e);
diff --git a/native/socket.react.js b/native/socket.react.js
--- a/native/socket.react.js
+++ b/native/socket.react.js
@@ -3,6 +3,7 @@
import invariant from 'invariant';
import * as React from 'react';
+import { useFetchPendingUpdates } from 'lib/actions/update-actions.js';
import { canResolveKeyserverSessionInvalidation } from 'lib/keyserver-conn/recovery-utils.js';
import { preRequestUserStateForSingleKeyserverSelector } from 'lib/selectors/account-selectors.js';
import {
@@ -123,6 +124,12 @@
.activeSessionRecovery,
);
+ const fetchPendingUpdates = useFetchPendingUpdates();
+
+ const isConnectedToInternet = useSelector(
+ state => state.connectivity.connected,
+ );
+
return (
<Socket
{...props}
@@ -144,6 +151,8 @@
lastCommunicatedPlatformDetails={lastCommunicatedPlatformDetails}
decompressSocketMessage={decompressMessage}
activeSessionRecovery={activeSessionRecovery}
+ fetchPendingUpdates={fetchPendingUpdates}
+ isConnectedToInternet={isConnectedToInternet}
/>
);
});
diff --git a/web/socket.react.js b/web/socket.react.js
--- a/web/socket.react.js
+++ b/web/socket.react.js
@@ -3,6 +3,7 @@
import invariant from 'invariant';
import * as React from 'react';
+import { useFetchPendingUpdates } from 'lib/actions/update-actions.js';
import { preRequestUserStateForSingleKeyserverSelector } from 'lib/selectors/account-selectors.js';
import {
cookieSelector,
@@ -15,6 +16,7 @@
import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js';
import { useDispatch } from 'lib/utils/redux-utils.js';
+import { useNetworkConnected } from './redux/keyserver-reachability-handler.js';
import { useSelector } from './redux/redux-utils.js';
import {
activeThreadSelector,
@@ -85,6 +87,10 @@
.activeSessionRecovery,
);
+ const fetchPendingUpdates = useFetchPendingUpdates();
+
+ const isConnectedToInternet = useNetworkConnected();
+
return (
<Socket
{...props}
@@ -104,6 +110,8 @@
lastCommunicatedPlatformDetails={lastCommunicatedPlatformDetails}
decompressSocketMessage={decompressMessage}
activeSessionRecovery={activeSessionRecovery}
+ fetchPendingUpdates={fetchPendingUpdates}
+ isConnectedToInternet={isConnectedToInternet}
/>
);
});

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 9:08 PM (20 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678868
Default Alt Text
D12369.diff (5 KB)

Event Timeline