Wait 2s before checking for matching devices for connected clients

Summary:
Currently when a client connects, if there's no matching device we know of, it emits an error.

The problem is that there's a race between clients connecting and devices being detected, if the client connects first, then we'll emit this error, even though the device is displayed shortly afterwards.

Fixing this by waiting 2 seconds after a client connects, and then if it's still connected, checking for a matching device. This should be enough time to make this error more reliable.

Reviewed By: passy

Differential Revision: D14126315

fbshipit-source-id: c81b2c6d9a6e0639a656d1a4d7a8f999f715bfbf
This commit is contained in:
John Knox
2019-02-19 03:43:07 -08:00
committed by Facebook Github Bot
parent 77c77b5eb3
commit 6bdbb4f763
2 changed files with 31 additions and 10 deletions

View File

@@ -21,6 +21,13 @@ export default (store: Store, logger: Logger) => {
type: 'NEW_CLIENT',
payload: client,
});
// Wait 2 seconds, and then trigger another event so we can check it's displayed
setTimeout(() => {
store.dispatch({
type: 'NEW_CLIENT_SANITY_CHECK',
payload: client,
});
}, 2000);
});
server.addListener('removed-client', (id: string) => {