Add FlipperServerDisconnectedError to prevent excessive error logging
Reviewed By: passy Differential Revision: D51393196 fbshipit-source-id: f49857b397a3fb629ad44f89a4c59b12ba2f67c4
This commit is contained in:
committed by
Facebook GitHub Bot
parent
7c972a982a
commit
d515342526
@@ -54,6 +54,7 @@ export {
|
||||
isConnectivityOrAuthError,
|
||||
isError,
|
||||
isAuthError,
|
||||
FlipperServerDisconnectedError,
|
||||
getStringFromErrorLike,
|
||||
getErrorFromErrorLike,
|
||||
deserializeRemoteError,
|
||||
|
||||
@@ -96,6 +96,12 @@ export class NoLongerConnectedToClientError extends Error {
|
||||
name: 'NoLongerConnectedToClientError';
|
||||
}
|
||||
|
||||
export class FlipperServerDisconnectedError extends Error {
|
||||
constructor(public readonly reason: 'ws-close') {
|
||||
super(`Flipper Server disconnected. Reason: ${reason}`);
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Error {
|
||||
interaction?: unknown;
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
InstalledPluginDetails,
|
||||
tryCatchReportPluginFailuresAsync,
|
||||
notNull,
|
||||
FlipperServerDisconnectedError,
|
||||
} from 'flipper-common';
|
||||
import {ActivatablePluginDetails, ConcretePluginDetails} from 'flipper-common';
|
||||
import {reportUsage} from 'flipper-common';
|
||||
@@ -229,7 +230,15 @@ export const createRequirePluginFunction =
|
||||
return pluginDefinition;
|
||||
} catch (e) {
|
||||
failedPlugins.push([pluginDetails, e.message]);
|
||||
console.error(`Plugin ${pluginDetails.id} failed to load`, e);
|
||||
|
||||
let severity: 'error' | 'warn' = 'error';
|
||||
if (
|
||||
e instanceof FlipperServerDisconnectedError &&
|
||||
e.reason === 'ws-close'
|
||||
) {
|
||||
severity = 'warn';
|
||||
}
|
||||
console[severity](`Plugin ${pluginDetails.id} failed to load`, e);
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
FlipperServerCommands,
|
||||
FlipperServerExecOptions,
|
||||
ServerWebSocketMessage,
|
||||
FlipperServerDisconnectedError,
|
||||
} from 'flipper-common';
|
||||
import ReconnectingWebSocket from 'reconnecting-websocket';
|
||||
|
||||
@@ -90,7 +91,7 @@ export function createFlipperServerWithSocket(
|
||||
onStateChange(FlipperServerState.DISCONNECTED);
|
||||
|
||||
pendingRequests.forEach((r) =>
|
||||
r.reject(new Error('flipper-server disconnected')),
|
||||
r.reject(new FlipperServerDisconnectedError('ws-close')),
|
||||
);
|
||||
pendingRequests.clear();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user