Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32301133
D12369.1765285871.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D12369.1765285871.diff
View Options
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,7 @@
reopenConnectionAfterClosing: boolean = false;
initializedWithUserState: ?PreRequestUserState;
initFailureCountAfterPolicyAcknowledgment: number = 0;
+ initFailureCount: number = 0;
openSocket(newStatus: ConnectionStatus) {
if (
@@ -437,6 +443,7 @@
return;
}
this.initFailureCountAfterPolicyAcknowledgment = 0;
+ this.initFailureCount = 0;
const { inflightRequests } = this.state;
if (!inflightRequests) {
@@ -678,11 +685,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 +707,17 @@
},
});
return;
+ } else if (this.initFailureCount >= 2) {
+ this.initFailureCountAfterPolicyAcknowledgment = 0;
+ this.initFailureCount = 0;
+ const sessionState = this.props.sessionStateFunc();
+ void this.props.dispatchActionPromise(
+ fetchPendingUpdatesActionTypes,
+ this.props.fetchPendingUpdates({
+ ...sessionState,
+ keyserverID: this.props.keyserverID,
+ }),
+ );
}
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
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 9, 1:11 PM (11 h, 6 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5854494
Default Alt Text
D12369.1765285871.diff (5 KB)
Attached To
Mode
D12369: [lib][native][web] Recover from socket crash loop using fetchPendingUpdates
Attached
Detach File
Event Timeline
Log In to Comment