Switch SQL to main process on disconnect
This commit is contained in:
parent
35530a4832
commit
2d596ac8b2
2 changed files with 10 additions and 21 deletions
|
@ -3417,26 +3417,6 @@ export async function startApp(): Promise<void> {
|
|||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
error instanceof HTTPError &&
|
||||
(error.code === -1 || error.code === 502)
|
||||
) {
|
||||
// Failed to connect to server
|
||||
if (navigator.onLine) {
|
||||
const timeout = reconnectBackOff.getAndIncrement();
|
||||
|
||||
log.info(`retrying in ${timeout}ms`);
|
||||
reconnectTimer = Timers.setTimeout(connect, timeout);
|
||||
|
||||
window.Whisper.events.trigger('reconnectTimer');
|
||||
|
||||
// If we couldn't connect during startup - we should still switch SQL to
|
||||
// the main process to avoid stalling UI.
|
||||
window.Signal.Data.goBackToMainProcess();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
log.warn('background onError: Doing nothing with incoming error');
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import type {
|
|||
import { getSocketStatus } from '../shims/socketStatus';
|
||||
import * as log from '../logging/log';
|
||||
import { SECOND } from '../util/durations';
|
||||
import { SocketStatus } from '../types/SocketStatus';
|
||||
|
||||
type NetworkActions = {
|
||||
checkNetworkStatus: (x: CheckNetworkStatusPayloadType) => NetworkActionType;
|
||||
|
@ -20,9 +21,17 @@ export function initializeNetworkObserver(
|
|||
log.info('Initializing network observer');
|
||||
|
||||
const refresh = () => {
|
||||
const socketStatus = getSocketStatus();
|
||||
|
||||
if (socketStatus === SocketStatus.CLOSED) {
|
||||
// If we couldn't connect during startup - we should still switch SQL to
|
||||
// the main process to avoid stalling UI.
|
||||
window.Signal.Data.goBackToMainProcess();
|
||||
}
|
||||
|
||||
networkActions.checkNetworkStatus({
|
||||
isOnline: navigator.onLine,
|
||||
socketStatus: getSocketStatus(),
|
||||
socketStatus,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue