Don't attempt to connect to devtools in non-browser environments#11971
Don't attempt to connect to devtools in non-browser environments#11971jerelmiller merged 4 commits intomainfrom
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 📦
|
| setTimeout(() => { | ||
| if ( | ||
| typeof window !== "undefined" && | ||
| window.document && |
There was a problem hiding this comment.
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.
| if ( | ||
| window.document && | ||
| window.top === window.self && | ||
| !(window as any).__APOLLO_DEVTOOLS_GLOBAL_HOOK__ && |
There was a problem hiding this comment.
!(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.
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.
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. |
✅ 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 windowto set the default value fordevtools.enabled. TheconnectToDevtoolsfunction has some checks fortypeof windowas well, but currently it allows thesetTimeoutto run before it checks fortypeof window.This PR simplifies this by returning early if
typeof windowisundefined.