-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix intermittent issue where a page refresh or navigation might mistakenly connect but show no data #1378
Conversation
@@ -87,12 +87,13 @@ export function createDevtoolsMachine({ actions }: { actions: Actions }) { | |||
timeout: "timedout", | |||
clientNotFound: "notFound", | |||
}, | |||
entry: ["unsubscribeFromAll", "connectToClient"], | |||
entry: ["unsubscribeFromAll"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This ended up working very strangely because sometimes the connectToClient
event was sent before a page was fully unloaded, which caused some false-positives on determining when the client reconnected. Instead, we now just rely on the content script sending the registerContent
event to determine when to navigate back to the connected
state
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
entry: ["unsubscribeFromAll"], | |
entry: "unsubscribeFromAll", |
Just some consistency.
#412 Bundle Size — 1.26MiB (+0.02%).Warning Bundle contains 12 duplicate packages – View duplicate packages Bundle metrics
|
Current #412 |
Baseline #410 |
|
---|---|---|
Initial JS | 1.22MiB (+0.02% ) |
1.22MiB |
Initial CSS | 0B |
0B |
Cache Invalidation | 94.57% |
1.13% |
Chunks | 5 |
5 |
Assets | 12 |
12 |
Modules | 940 |
940 |
Duplicate Modules | 45 |
45 |
Duplicate Code | 3.82% |
3.82% |
Packages | 160 |
160 |
Duplicate Packages | 9 |
9 |
Bundle size by type 1 change
1 regression
Current #412 |
Baseline #410 |
|
---|---|---|
JS | 1.22MiB (+0.02% ) |
1.22MiB |
IMG | 35.85KiB |
35.85KiB |
HTML | 810B |
810B |
Other | 778B |
778B |
Bundle analysis report Branch jerel/register-event Project dashboard
| { type: "clientNotFound" } | ||
| { type: "connectToClient" } | ||
| { type: "connectToClientTimeout" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This wasn't used so no reason to keep it around.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Read the code, reproduced the bug, reproduced that this fixes it - LGTM :)
d5b73fb
to
90d4720
Compare
…end additional message from devtools
90d4720
to
ffc44d4
Compare
Our current disconnect event sent to the devtools prompts devtools to try and connect to the client again by sending the
connectToClient
message. This caused some weird issues where sometimes that event was triggered so fast that it re-discovered the old client before the page was fully unloaded. At times this seemed to cause issues where it was reported that the client was connected, but you saw no data.This PR introduces a new
registerClient
event sent by the content script that is fired when a client registered with the devtools to distinctly identify the event as such. Now when a disconnect happens, rather than pinging the content script over and over to try and determine if a client is connected, it will instead start a new timer, wait 10 seconds, and if theregisterClient
event hasn't occured within that time, will set itself to the "not found" state. This makes this behavior much more reliable between page refreshes and navigation.This PR also makes a small improvement by detecting if the client is able to connect again after it has found itself in the "not found" state. If, for example, you navigate to a page without Apollo loaded, then navigate back using the back button, it will re-connect itself and show the data in the devtools without first having to click the "retry" button.
If you want to validate some cases yourself, try doing these few things: