-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Don't attempt to connect to devtools in non-browser environments #11971
Conversation
🦋 Changeset detectedLatest commit: 272000f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
size-limit report 📦
|
src/core/ApolloClient.ts
Outdated
/** | ||
* Suggest installing the devtools for developers who don't have them | ||
*/ | ||
if (!hasSuggestedDevtools && __DEV__) { | ||
hasSuggestedDevtools = true; | ||
setTimeout(() => { | ||
if ( | ||
typeof window !== "undefined" && | ||
window.document && |
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.
Can you move this whole check (apart from the __APOLLO_DEVTOOLS_GLOBAL_HOOK_
) around the setTimeout
?
No need to schedule a timeout that won't do anything.
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.
Certainly!
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.
src/core/ApolloClient.ts
Outdated
if ( | ||
window.document && | ||
window.top === window.self && | ||
!(window as any).__APOLLO_DEVTOOLS_GLOBAL_HOOK__ && |
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.
!(window as any).__APOLLO_DEVTOOLS_GLOBAL_HOOK__ &&
This line needs to be inside the setTimeout
though as it should check after 10s - sorry for being confusing! 😅
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.
Yep just realized that 😆. I'm trying to move too fast and do too many things at once!
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.
🐌 🐌 🐌
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.
Perhaps this is the right combination: 272000f
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
Looks good to me
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for apollo-client-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
This was mostly already doing this. With #11969, we removed the check for
typeof window
to set the default value fordevtools.enabled
. TheconnectToDevtools
function has some checks fortypeof window
as well, but currently it allows thesetTimeout
to run before it checks fortypeof window
.This PR simplifies this by returning early if
typeof window
isundefined
.