Suggest a quick fix for EADDRINUSE
Summary: Show users a way to fix Flipper EADDRINUSE on their own without filing a support request CHANGELOG: Better error message for EADDRINUSE Reviewed By: mweststrate Differential Revision: D40338164 fbshipit-source-id: ec0419c78983b55736aa773757775b5302da51e0
This commit is contained in:
committed by
Facebook GitHub Bot
parent
eb4b83d0b6
commit
fbbd90e9f5
@@ -45,27 +45,15 @@ export function connectFlipperServerToStore(
|
|||||||
server.on('server-state', handleServerStateChange);
|
server.on('server-state', handleServerStateChange);
|
||||||
|
|
||||||
server.on('server-error', (err) => {
|
server.on('server-error', (err) => {
|
||||||
notification.error({
|
if (err.code === 'EADDRINUSE') {
|
||||||
message: 'Connection error',
|
handeEADDRINUSE('' + err);
|
||||||
description:
|
} else {
|
||||||
err.code === 'EADDRINUSE' ? (
|
notification.error({
|
||||||
<>
|
message: 'Connection error',
|
||||||
Couldn't start connection server. Looks like you have multiple
|
description: <>{err.message ?? err}</>,
|
||||||
copies of Flipper running or another process is using the same
|
duration: null,
|
||||||
port(s). As a result devices will not be able to connect to Flipper.
|
});
|
||||||
<br />
|
}
|
||||||
<br />
|
|
||||||
Please try to kill the offending process by running{' '}
|
|
||||||
<code>kill $(lsof -ti:PORTNUMBER)</code> and restart flipper.
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
{'' + err}
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<>{err.message ?? err}</>
|
|
||||||
),
|
|
||||||
duration: null,
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
server.on('device-connected', (deviceInfo) => {
|
server.on('device-connected', (deviceInfo) => {
|
||||||
@@ -189,16 +177,41 @@ function handleServerStateChange({
|
|||||||
}) {
|
}) {
|
||||||
if (state === 'error') {
|
if (state === 'error') {
|
||||||
console.warn(`[conn] Flipper server state -> ${state}`, error);
|
console.warn(`[conn] Flipper server state -> ${state}`, error);
|
||||||
notification.error({
|
if (error?.includes('EADDRINUSE')) {
|
||||||
message: 'Failed to start flipper-server',
|
handeEADDRINUSE(error);
|
||||||
description: '' + error,
|
} else {
|
||||||
duration: null,
|
notification.error({
|
||||||
});
|
message: 'Failed to start flipper-server',
|
||||||
|
description: '' + error,
|
||||||
|
duration: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.info(`[conn] Flipper server state -> ${state}`);
|
console.info(`[conn] Flipper server state -> ${state}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handeEADDRINUSE(errorMessage: string) {
|
||||||
|
notification.error({
|
||||||
|
message: 'Connection error',
|
||||||
|
description: (
|
||||||
|
<>
|
||||||
|
Couldn't start connection server. Looks like you have multiple copies of
|
||||||
|
Flipper running or another process is using the same port(s). As a
|
||||||
|
result devices will not be able to connect to Flipper.
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
Please try to kill the offending process by running{' '}
|
||||||
|
<code>kill $(lsof -ti:PORTNUMBER)</code> and restart flipper.
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
{errorMessage}
|
||||||
|
</>
|
||||||
|
),
|
||||||
|
duration: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
export function handleDeviceConnected(
|
export function handleDeviceConnected(
|
||||||
server: FlipperServer,
|
server: FlipperServer,
|
||||||
store: Store,
|
store: Store,
|
||||||
|
|||||||
Reference in New Issue
Block a user