Clean up some redundant logic for connecting to the client#1392
Clean up some redundant logic for connecting to the client#1392jerelmiller merged 10 commits intomainfrom
Conversation
#508 Bundle Size — 1.27MiB (-0.04%).Warning Bundle contains 12 duplicate packages – View duplicate packages Bundle metrics
Bundle size by type
Bundle analysis report Branch jerel/better-connect-timeout Project dashboard |
| * Attempt to find the client on a 1-second interval for 10 seconds max | ||
| */ | ||
| let interval: NodeJS.Timeout; | ||
| function findClient() { |
There was a problem hiding this comment.
We no longer need this at all since we send a registerClient message any time the client is registered which will connect it for us.
| if (hook.ApolloClient) { | ||
| sendHookDataToDevTools("connectToDevtools"); | ||
| } else { | ||
| findClient(); |
There was a problem hiding this comment.
The devtools script will now try to connect and then wait up to 10 seconds for a registerClient or connectToDevtools message before giving up and showing the not found modal. Since we can rely on those messages instead, we don't need to try and find a client when this connectToClient message is sent.
In the future, this connectToClient could likely be replaced with an RPC call to simplify this a bit further. This adds a bit of complexity though to do this in this PR so I'll do this separately to keep this PR clean.
| connectedToPanel = true; | ||
| } | ||
|
|
||
| if (devtoolsMachine.state.value === "initialized") { |
There was a problem hiding this comment.
This is no longer needed since the rest of the messages are now robust enough to not have to "retry" connecting when the panel is first shown 🎉
alessbell
left a comment
There was a problem hiding this comment.
Nice that we no longer need findClient! 🚀
1aa093f to
8e2e206
Compare
With the updated registration mechanism added in #1375, we can simplify the way the connect timeouts are handled and remove some redundant logic for trying to find the client. This PR simplifies this mechanism to remove some redundancy.