Skip to content

Clean up some redundant logic for connecting to the client#1392

Merged
jerelmiller merged 10 commits intomainfrom
jerel/better-connect-timeout
Jun 6, 2024
Merged

Clean up some redundant logic for connecting to the client#1392
jerelmiller merged 10 commits intomainfrom
jerel/better-connect-timeout

Conversation

@jerelmiller
Copy link
Copy Markdown
Member

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.

@jerelmiller jerelmiller requested a review from a team as a code owner May 29, 2024 05:56
@jerelmiller jerelmiller requested review from alessbell and phryneas May 29, 2024 05:56
@relativeci
Copy link
Copy Markdown

relativeci bot commented May 29, 2024

#508 Bundle Size — 1.27MiB (-0.04%).

8e2e206(current) vs 59a4500 main#507(baseline)

Warning

Bundle contains 12 duplicate packages – View duplicate packages

Bundle metrics  Change 2 changes Improvement 1 improvement
                 Current
#508
     Baseline
#507
Improvement  Initial JS 1.23MiB(-0.04%) 1.23MiB
No change  Initial CSS 0B 0B
Change  Cache Invalidation 3.42% 92.31%
No change  Chunks 5 5
No change  Assets 12 12
No change  Modules 946 946
No change  Duplicate Modules 45 45
No change  Duplicate Code 3.87% 3.87%
No change  Packages 160 160
No change  Duplicate Packages 9 9
Bundle size by type  Change 1 change Improvement 1 improvement
                 Current
#508
     Baseline
#507
Improvement  JS 1.23MiB (-0.04%) 1.23MiB
No change  IMG 35.85KiB 35.85KiB
No change  HTML 810B 810B
No change  Other 778B 778B

Bundle analysis reportBranch jerel/better-connect-timeoutProject dashboard

Comment thread src/extension/tab/hook.ts
* Attempt to find the client on a 1-second interval for 10 seconds max
*/
let interval: NodeJS.Timeout;
function findClient() {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/extension/tab/hook.ts
if (hook.ApolloClient) {
sendHookDataToDevTools("connectToDevtools");
} else {
findClient();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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") {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🎉

Copy link
Copy Markdown
Contributor

@alessbell alessbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice that we no longer need findClient! 🚀

@jerelmiller jerelmiller force-pushed the jerel/better-connect-timeout branch from 1aa093f to 8e2e206 Compare June 6, 2024 17:18
@jerelmiller jerelmiller merged commit c9764ea into main Jun 6, 2024
@jerelmiller jerelmiller deleted the jerel/better-connect-timeout branch June 6, 2024 17:23
@github-actions github-actions bot mentioned this pull request Jun 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants