Better error for ports in use

Summary:
If port 8088 / 8089 are in use, devices will not be able to connect to Flipper. We have checks for this in place, however it turns out that users can miss them. Potentially this can be caused for mulltiple reasons:

1. The notification is shown fairly short (in my testing it disappeared sometimes in < 2 secs
2. The notification is shown outside of the Flipper area
3. Flipper might not have permissions to show notifs in the first place.

Changed the notification to show inside Flipper, not hide automatically, and added clearer instructions. Including mentioning the port number (since there are multiple)

Changelog: [Flipper] Provide clearer error if Flipper ports are already in use, making device connections impossible

Differential Revision: D29128014

fbshipit-source-id: 16d9b451aa84281744155bfa1042429911a7b774
This commit is contained in:
Michel Weststrate
2021-06-15 06:27:32 -07:00
committed by Facebook GitHub Bot
parent 6754ccb8dc
commit 42c4bfcb47

View File

@@ -18,7 +18,7 @@ import {CertificateExchangeMedium} from '../utils/CertificateProvider';
import {selectClient, selectDevice} from '../reducers/connections'; import {selectClient, selectDevice} from '../reducers/connections';
import {isLoggedIn} from '../fb-stubs/user'; import {isLoggedIn} from '../fb-stubs/user';
import React from 'react'; import React from 'react';
import {Typography} from 'antd'; import {notification, Typography} from 'antd';
import {ACTIVE_SHEET_SIGN_IN, setActiveSheet} from '../reducers/application'; import {ACTIVE_SHEET_SIGN_IN, setActiveSheet} from '../reducers/application';
export default (store: Store, logger: Logger) => { export default (store: Store, logger: Logger) => {
@@ -30,14 +30,27 @@ export default (store: Store, logger: Logger) => {
}); });
server.addListener('error', (err) => { server.addListener('error', (err) => {
store.dispatch( notification.error({
addErrorNotification( message: 'Failed to start connection server',
'Failed to start websocket server', description:
err.code === 'EADDRINUSE' err.code === 'EADDRINUSE' ? (
? "Couldn't start websocket server. Looks like you have multiple copies of Flipper running." <>
: err.message || 'Unknown error', 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 />
{'' + err}
</>
) : (
<>Failed to start connection server: ${err.message}</>
),
duration: null,
});
}); });
server.addListener('start-client-setup', (client: UninitializedClient) => { server.addListener('start-client-setup', (client: UninitializedClient) => {