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

[Question] Best practices with Gatsby Cloud (Unsafe method warning when building) #10

Closed
ardiewen opened this issue Jun 14, 2021 · 2 comments

Comments

@ardiewen
Copy link

Hi @trevorblades, while I don't use this plugin directly, my configuration is more or less identical to it.

Recently in Gatsby v3, we started seeing "Unsafe built-in method was used" warnings as documented in the discussion thread I created here:
gatsbyjs/gatsby#31753

TL;DR: It seems that any use of node-fetch throws these warnings that could potentially have impact on users who are on Gatsby Cloud (e.g. causes a full build vs incremental build).

All documentation from both Gatsby and Apollo to date has been pushing towards this configuration:

  1. using an isomorphic fetch library
  2. wrapping the Apollo Provider in both gatsby-browser.js AND gatsby-ssr.js

This seems to be problematic for Gatsby now. I haven't heard back from the Gatsby team on how to proceed, but I've also created a "Apollo Provider on Client-Side Only" test on my minimal repro here:
ardiewen/gatsby-with-apollo-warning#1

I wanted to get your thoughts on this. The PR on my minimal repro no longer produces the "Unsafe built-in method" warning on build, but it DOES force components with hooks such as useQuery to be tested against client-side only logic. Otherwise, it will throw an SSR invariant violation error.

@trevorblades
Copy link
Owner

Hey @ardiewen, do you know if node-fetch and isomorphic-fetch both share this problem when building for Gatsby Cloud? Did your discussion with the Gatsby team yield any new insight about this problem?

I've never personally seen this issue. Does it happen when building Gatsby v3 locally, or only on Gatsby Cloud? And does it happen when you're using this plugin, or your custom configuration? (or both?)

@ardiewen
Copy link
Author

ardiewen commented Jul 9, 2021

Hey @trevorblades , thanks for getting back to me. I opened the minimal reproduction again to verify based on your questions:

  • this is strictly a Gatsby Cloud issue. Building locally or on Netlify doesn't produce this warning.

  • isomorphic-fetch DOESN'T have this issue while cross-fetch AND isomorphic-unfetch do

  • isomorphic-fetch is implemented as a polyfill, while the others are implemented as ponyfill, so i tested the other two libraries as polyfills but unfortunately they still throw the same warning...

  • isomorphic-fetch throws other errors / warnings, such as Node.js - realFetch.call is not a function  matthew-andrews/isomorphic-fetch#194 , which is why we switched to cross-fetch in the first place.

Anyway, doesn't seem like its an Apollo implementation issue now, so I'll relay this info back to the Gatsby team. Thanks again for your reply.

@ardiewen ardiewen closed this as completed Jul 9, 2021
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

No branches or pull requests

2 participants