Show possible remediation steps for known errors in a notification
Summary: This diff fires a notification with a remediation suggestion when the client takes a long time to connect back, for both WW and FS_ACCESS case Reviewed By: mweststrate Differential Revision: D23321067 fbshipit-source-id: 17ab93974e9571a0ba78af05c624eeb0522637c6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
ce12c4e3df
commit
dc4e224bfb
@@ -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();
|
||||
|
||||
@@ -87,7 +87,7 @@ class Server extends EventEmitter {
|
||||
logger: Logger;
|
||||
store: Store;
|
||||
initialisePromise: Promise<void> | 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,
|
||||
|
||||
Reference in New Issue
Block a user