-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
Error in function useStaticQuery in ./.cache/gatsby-browser-entry.js:77 (After upgrade to v3) #29951
Comments
@logemann can you share your project or create any reproduction? Have you ran |
yeah i ran
But like i said. If the query would be broken, it wouldnt work after changing something and hit save. Unfortunately you only see a query number inside Currently i cant expose the whole project. |
It seems it has something to do with gatsby-plugin-netlify-cms. When i remove this plugin, the error disappears. |
The same happened to me, after the update to Gatsby 3 i had the error. In my case the error was in the index.js page. Instead of using export const query = graphql`.... And changed the page in order to automatically receive data: const IndexPage = ({data}) => { Please note that i have netflify-cms but i didn't remove them as it should not be the real problem UPDATE: all my previous info are wrong since the error is still here and as @logemann says it goes away at the first change (you can just save a file, triggering the site reload). |
Nope
|
Please upgrade to the latest version of all packages (we added some improvements to error handling in |
I've tried to upgrade everything yesterday, including the [email protected], didn't help. I'm builing a repro right now... |
@LekoArts my minimal reproduction is ready https://github.com/yurist38/gatsby-3-static-query-issue |
@yurist38 i dont use MDX. So the error is not related to that. |
Having the same problem, neither |
Having the same issue on Mac OS machine, while the project is running completely fine on a Windows machine. I've tried updating/upgrading all the packages to the latest version, but it still just displays the same error. |
@yurist38 I followed the steps in the README and can't reproduce it. I also tried it with For the rest: Please provide a reproduction if possible, only this way we can help :) Thanks! |
@LekoArts it seems like something has changed since then. I've just tested it again with this reproduction repo and the issue is not appearing anymore... 🤔 Let me do more tests with my project next few days. I'll keep you updated. |
I got the same error on a clean project based on the blog starter with only 'netlify-cms-app' and 'netlify-cms-media-library-cloudinary' added. Here you are the error message after the deploy: Unhandled Runtime Error Error in function useStaticQuery in ./.cache/gatsby-browser-entry.js:77The result of this StaticQuery could not be fetched. This is likely a bug in Gatsby and if refreshing the page does not fix it, please open an issue in https://github.com/gatsbyjs/gatsby/issues
And here you are the error I got during the build:
|
Facing the same issue (working on Windows but not on Mac) with both StaticQuery component and useStaticQuery hook. It starts working when I make a pseudo change in the component using the static query.
Reproduction Repo: https://github.com/phipag/gatsby-i18n The production build and deploy to Netlify is working and the error only happens in development mode. |
I can now confirm that this issue does not appear when removing gatsby-plugin-netlify-cms. Maybe this is related to the changes to the webpack config the plugin makes: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-netlify-cms/src/gatsby-node.js#L82 |
While this is fixed in gatsby, I can share the configuration that fixed the issue for me: {
resolve: "gatsby-plugin-netlify-cms",
options: {
...yourOtherOptions,
customizeWebpackConfig: (config) => {
config.plugins = config.plugins.filter(
(plugin) => plugin.constructor.name !== "StaticQueryMapper"
);
},
},
} If this is confirmed, it will just be a matter of adding that string to
|
@ridem Thanks for sharing. It finally works now! Definitely worth adding this to the plugin directly so that others will not be affected by that anymore. |
The Netlify CMS plugin is spinning an extra webpack instance with almost every plugin from gatsby. Reusing the `StaticQueryMapper` plugin caused issues given how it's dealing with a Gatsby state. Fixes gatsbyjs#29951 This commit also: - removes `cssTests` which wasn't used anymore - adds a clear TODO for how to get `excludeAssets` to be taken into account again
The Netlify CMS plugin is spinning an extra webpack instance with almost every plugin from gatsby. Reusing the `StaticQueryMapper` plugin caused issues given how it's dealing with a Gatsby state. Fixes #29951 This commit also: - removes `cssTests` which wasn't used anymore - adds a clear TODO for how to get `excludeAssets` to be taken into account again
Description
After starting (yarn start) a migrated gatsby v3 project, i am getting a weird error in the frontend (see screenshot). When using browser console i see some stacktraces involving my SEO component (which has a very basic and fully functional staticQuery expression in there) and a stacktrace regarding reach router.
This error stays but when i make a modification to the source, lets say i change a letter in the JSX, the error disappears and i have my running site.
On the shell i see this after saving my pseudo change (after that everything works)
See below the stacktrace in the browser console when being in error mode:
(i shortened the stacktrace a little bit.)
Steps to reproduce
for me it was just starting the project.
Expected result
fully functional gatsby project ;-)
Actual result
this error screenshot.
Environment
System:
OS: macOS 11.2.1
CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
Shell: 5.8 - /bin/zsh
Binaries:
Node: 15.8.0 - /usr/local/bin/node
Yarn: 1.22.10 - /usr/local/bin/yarn
npm: 7.5.0 - /usr/local/bin/npm
Languages:
Python: 3.9.0 - /Users/ml/.pyenv/shims/python
Browsers:
Chrome: 88.0.4324.192
Safari: 14.0.3
npmPackages:
gatsby: ^3.0.0 => 3.0.0
gatsby-image: ^3.0.0 => 3.0.0
gatsby-plugin-google-analytics-reporter: ^1.1.1 => 1.1.1
gatsby-plugin-google-fonts: ^1.0.1 => 1.0.1
gatsby-plugin-google-tagmanager: ^3.0.0 => 3.0.0
gatsby-plugin-html-attributes: ^1.0.5 => 1.0.5
gatsby-plugin-image: ^1.0.0 => 1.0.0
gatsby-plugin-manifest: ^3.0.0 => 3.0.0
gatsby-plugin-netlify: ^3.0.0 => 3.0.0
gatsby-plugin-netlify-cms: ^5.0.0 => 5.0.0
gatsby-plugin-percy: ^0.1.4 => 0.1.4
gatsby-plugin-react-helmet: ^4.0.0 => 4.0.0
gatsby-plugin-react-helmet-canonical-urls: ^1.4.0 => 1.4.0
gatsby-plugin-react-svg: ^3.0.0 => 3.0.0
gatsby-plugin-robots-txt: ^1.5.5 => 1.5.5
gatsby-plugin-sass: ^4.0.0 => 4.0.0
gatsby-plugin-sharp: ^3.0.0 => 3.0.0
gatsby-plugin-sitemap: ^3.0.0 => 3.0.0
gatsby-plugin-styled-components: ^4.0.0 => 4.0.0
gatsby-remark-classes: ^1.0.0 => 1.0.0
gatsby-remark-copy-linked-files: ^3.0.0 => 3.0.0
gatsby-remark-custom-blocks: ^3.0.0 => 3.0.0
gatsby-remark-images: ^4.0.0 => 4.0.0
gatsby-remark-prismjs: ^4.0.0 => 4.0.0
gatsby-remark-relative-images: ^2.0.2 => 2.0.2
gatsby-source-filesystem: ^3.0.0 => 3.0.0
gatsby-transformer-json: ^3.0.0 => 3.0.0
gatsby-transformer-remark: ^3.0.0 => 3.0.0
gatsby-transformer-sharp: ^3.0.0 => 3.0.0
npmGlobalPackages:
gatsby-cli: 2.12.110
The text was updated successfully, but these errors were encountered: