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,
|
isConnectivityOrAuthError,
|
||||||
isError,
|
isError,
|
||||||
isAuthError,
|
isAuthError,
|
||||||
|
FlipperServerDisconnectedError,
|
||||||
getStringFromErrorLike,
|
getStringFromErrorLike,
|
||||||
getErrorFromErrorLike,
|
getErrorFromErrorLike,
|
||||||
deserializeRemoteError,
|
deserializeRemoteError,
|
||||||
|
|||||||
@@ -96,6 +96,12 @@ export class NoLongerConnectedToClientError extends Error {
|
|||||||
name: 'NoLongerConnectedToClientError';
|
name: 'NoLongerConnectedToClientError';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class FlipperServerDisconnectedError extends Error {
|
||||||
|
constructor(public readonly reason: 'ws-close') {
|
||||||
|
super(`Flipper Server disconnected. Reason: ${reason}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
interface Error {
|
interface Error {
|
||||||
interaction?: unknown;
|
interaction?: unknown;
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import {
|
|||||||
InstalledPluginDetails,
|
InstalledPluginDetails,
|
||||||
tryCatchReportPluginFailuresAsync,
|
tryCatchReportPluginFailuresAsync,
|
||||||
notNull,
|
notNull,
|
||||||
|
FlipperServerDisconnectedError,
|
||||||
} from 'flipper-common';
|
} from 'flipper-common';
|
||||||
import {ActivatablePluginDetails, ConcretePluginDetails} from 'flipper-common';
|
import {ActivatablePluginDetails, ConcretePluginDetails} from 'flipper-common';
|
||||||
import {reportUsage} from 'flipper-common';
|
import {reportUsage} from 'flipper-common';
|
||||||
@@ -229,7 +230,15 @@ export const createRequirePluginFunction =
|
|||||||
return pluginDefinition;
|
return pluginDefinition;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
failedPlugins.push([pluginDetails, e.message]);
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import {
|
|||||||
FlipperServerCommands,
|
FlipperServerCommands,
|
||||||
FlipperServerExecOptions,
|
FlipperServerExecOptions,
|
||||||
ServerWebSocketMessage,
|
ServerWebSocketMessage,
|
||||||
|
FlipperServerDisconnectedError,
|
||||||
} from 'flipper-common';
|
} from 'flipper-common';
|
||||||
import ReconnectingWebSocket from 'reconnecting-websocket';
|
import ReconnectingWebSocket from 'reconnecting-websocket';
|
||||||
|
|
||||||
@@ -90,7 +91,7 @@ export function createFlipperServerWithSocket(
|
|||||||
onStateChange(FlipperServerState.DISCONNECTED);
|
onStateChange(FlipperServerState.DISCONNECTED);
|
||||||
|
|
||||||
pendingRequests.forEach((r) =>
|
pendingRequests.forEach((r) =>
|
||||||
r.reject(new Error('flipper-server disconnected')),
|
r.reject(new FlipperServerDisconnectedError('ws-close')),
|
||||||
);
|
);
|
||||||
pendingRequests.clear();
|
pendingRequests.clear();
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user