diff --git a/desktop/app/src/dispatcher/server.tsx b/desktop/app/src/dispatcher/server.tsx index be8445586..ee4aee572 100644 --- a/desktop/app/src/dispatcher/server.tsx +++ b/desktop/app/src/dispatcher/server.tsx @@ -14,7 +14,7 @@ import {Logger} from '../fb-interfaces/Logger'; import Client from '../Client'; import {UninitializedClient} from '../UninitializedClient'; import {addErrorNotification} from '../reducers/notifications'; - +import {CertificateExchangeMedium} from '../utils/CertificateProvider'; export default (store: Store, logger: Logger) => { const server = new Server(logger, store); server.init(); @@ -83,6 +83,28 @@ export default (store: Store, logger: Logger) => { }, ); + server.addListener( + 'client-unresponsive-error', + ({ + client, + medium, + deviceID, + }: { + client: UninitializedClient; + medium: CertificateExchangeMedium; + deviceID: string; + }) => { + store.dispatch( + addErrorNotification( + `Client ${client.appName} with device ${deviceID} took long time to connect back on the trusted channel.`, + medium === 'WWW' + ? 'Verify that you are on lighthouse on your client and have a working internet connection. To connect to lighthouse on your client, use VPN. Follow this link: https://www.internalfb.com/intern/wiki/Ops/Network/Enterprise_Network_Engineering/ene_wlra/VPN_Help/Vpn/mobile/' + : 'Verify if your client is connected to Flipper and verify if there is no error related to idb.', + ), + ); + }, + ); + if (typeof window !== 'undefined') { window.addEventListener('beforeunload', () => { server.close(); diff --git a/desktop/app/src/server.tsx b/desktop/app/src/server.tsx index ac0bd7be7..c156f3c29 100644 --- a/desktop/app/src/server.tsx +++ b/desktop/app/src/server.tsx @@ -87,7 +87,7 @@ class Server extends EventEmitter { logger: Logger; store: Store; initialisePromise: Promise | null; - + timeHandler: NodeJS.Timeout | undefined; constructor(logger: Logger, store: Store) { super(); this.logger = logger; @@ -98,6 +98,7 @@ class Server extends EventEmitter { this.insecureServer = null; this.initialisePromise = null; this.store = store; + this.timeHandler = undefined; } init() { @@ -276,6 +277,9 @@ class Server extends EventEmitter { if (!payload.data) { return {}; } + if (this.timeHandler) { + clearTimeout(this.timeHandler); + } const clientData: ClientQuery & ClientCsrQuery & {medium: number | undefined} = JSON.parse(payload.data); this.connectionTracker.logConnectionAttempt(clientData); @@ -410,6 +414,16 @@ class Server extends EventEmitter { }), metadata: '', }); + + this.timeHandler = setTimeout(() => { + // Fire notification + this.emit('client-unresponsive-error', { + client, + medium: transformCertificateExchangeMediumToType(medium), + deviceID: result.deviceId, + }); + }, 30 * 1000); + this.emit('finish-client-setup', { client, deviceId: result.deviceId,