Skip to content
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

SSR with connectToDevTools enabled breaks app in NextJS #7453

Closed
krisgardiner opened this issue Dec 10, 2020 · 1 comment
Closed

SSR with connectToDevTools enabled breaks app in NextJS #7453

krisgardiner opened this issue Dec 10, 2020 · 1 comment
Assignees

Comments

@krisgardiner
Copy link

Intended outcome:

NextJS app should run server-side with connectToDevTools enabled.

Actual outcome:

NextJS app breaks server-side when connectToDevTools is enabled.

How to reproduce the issue:

  1. Create a NextJS app with @apollo/client and next-with-apollo
  2. When initializing ApolloClient, make sure options with ssrMode: true and connectToDevTools: true
  3. Should get a ReferenceError: window is not defined
> ReferenceError: window is not defined
> at new ApolloClient (/run/node_modules/@apollo/client/core/core.cjs.js:1682:13)
> at createApolloClient (/run/build/server/pages/_app.js:899:10)
> at getClient (/run/node_modules/next-with-apollo/lib/apollo.js:24:12)
> at Object.initApollo [as default] (/run/node_modules/next-with-apollo/lib/apollo.js:11:16)
> at /run/node_modules/next-with-apollo/lib/withApollo.js:105:54
> at step (/run/node_modules/next-with-apollo/lib/withApollo.js:44:23)
> at Object.next (/run/node_modules/next-with-apollo/lib/withApollo.js:25:53)
> at /run/node_modules/next-with-apollo/lib/withApollo.js:19:71
> at new Promise (<anonymous>)
> at __awaiter (/run/node_modules/next-with-apollo/lib/withApollo.js:15:12)

Versions

System:
    OS: macOS 10.15.7
  Binaries:
    Node: 14.15.1
    Yarn: 1.22.5
    npm: 6.14.8
  Browsers:
    Chrome: 87.0.4280.88
    Firefox: 83.0
    Safari: 14.0.1
  npmPackages:
    @apollo/client: 3.3.0 => 3.3.0 
    @apollo/react-testing: 4.0.0 => 4.0.0 
    apollo-cache-inmemory: 1.6.2 => 1.6.2 
    apollo-link: 1.2.2 => 1.2.2 
    apollo-link-context: 1.0.8 => 1.0.8 
    apollo-link-error: 1.1.11 => 1.1.11 
    apollo-link-http: 1.5.15 => 1.5.15 
    apollo-link-logger: 1.2.3 => 1.2.3 
    apollo-link-schema: 1.1.0 => 1.1.0 
    apollo-utilities: 1.3.2 => 1.3.2 
    next-with-apollo: 5.1.0 => 5.1.0 
    react-apollo: 2.5.8 => 2.5.8
benjamn added a commit that referenced this issue Dec 10, 2020
Since this message is promotional, I did not feel comfortable using
invariant.warn, but our default log level of "warn" would have hidden the
message unless setLogVerbosity("log") was called.

Since this is the only use of invariant.log in the codebase, I believe
it's acceptable to lower the default verbosity level to "log" to allow
this particular message to be displayed (otherwise, invariant.log messages
are effectively useless).

Fixes #7447 and #7453, since React Native polyfills the console object
without providing a console.debug method.
@benjamn benjamn self-assigned this Dec 10, 2020
benjamn added a commit that referenced this issue Dec 11, 2020
Since this message is promotional, I did not feel comfortable using
invariant.warn, but our default log level of "warn" would have hidden the
message unless setLogVerbosity("log") was called.

Since this is the only use of invariant.log in the codebase, I believe
it's acceptable to lower the default verbosity level to "log" to allow
this particular message to be displayed (otherwise, invariant.log messages
are effectively useless). You can use setLogVerbosity("warn") to exclude
these invariant.log messages if you like.

Fixes #7447 and #7453, since React Native polyfills the console object
without providing a console.debug method.
@benjamn
Copy link
Member

benjamn commented Dec 12, 2020

@krisgardiner This should be fixed in @apollo/client@3.3.6 (just published). Please feel free to reopen if you're still having issues. Thanks!

@benjamn benjamn closed this as completed Dec 12, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants