gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.27k stars 10.31k forks source link

Cannot start dev server: Missing onError handler for invocation 'extracting-queries', error was 'TypeError: Cannot read property 'filePath' of undefined'. #31374

Closed gustavo-a closed 3 years ago

gustavo-a commented 3 years ago

Description

Whenever I try to start the dev server I get the following message:

Missing onError handler for invocation 'extracting-queries', error was 'TypeError: Cannot read property 'filePath' of undefined'. Stacktrace was 'TypeError: Cannot read property 'filePath' of   
undefined

    at processDefinitions (C:\Projetos\ultimato-gatsby\node_modules\gatsby\src\query\query-compiler.js:306:22)
    at processQueries (C:\Projetos\ultimato-gatsby\node_modules\gatsby\src\query\query-compiler.js:176:10)
    at compile (C:\Projetos\ultimato-gatsby\node_modules\gatsby\src\query\query-compiler.js:78:19)
    at runMicrotasks (<anonymous>)
    at runNextTicks (internal/process/task_queues.js:62:5)
    at processImmediate (internal/timers.js:434:9)
    at updateStateAndRunQueries (C:\Projetos\ultimato-gatsby\node_modules\gatsby\src\query\query-watcher.ts:222:40)
    at extractQueries (C:\Projetos\ultimato-gatsby\node_modules\gatsby\src\services\extract-queries.ts:18:3)'

It happens right after onPreExtractQueries. Then it just freezes with the message "extract queries from components".

I'm trying to debug this for a while, but no success 🤕

Expected result

Dev server should run normally

Environment

System: OS: Windows 10 10.0.19042 CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz Binaries: Node: 12.19.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Spartan (44.19041.906.0), Chromium (90.0.818.56) npmPackages: gatsby: ^3.4.0 => 3.4.2 gatsby-awesome-pagination: ^0.3.8 => 0.3.8 gatsby-plugin-advanced-sitemap: ^1.6.0 => 1.6.0 gatsby-plugin-breadcrumb: ^12.1.0 => 12.1.0 gatsby-plugin-emotion: ^6.2.0 => 6.2.0 gatsby-plugin-gatsby-cloud: ^2.2.0 => 2.2.0 gatsby-plugin-html-attributes: ^1.0.5 => 1.0.5 gatsby-plugin-image: ^1.3.0 => 1.3.0 gatsby-plugin-manifest: ^3.2.0 => 3.2.0 gatsby-plugin-next-seo: ^1.7.0 => 1.7.0 gatsby-plugin-nprogress: ^3.2.0 => 3.2.0 gatsby-plugin-offline: ^4.2.0 => 4.2.0 gatsby-plugin-postcss: ^4.2.0 => 4.2.0 gatsby-plugin-preload-link-crossorigin: ^1.0.2 => 1.0.2 gatsby-plugin-react-helmet: ^4.2.0 => 4.2.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.2.0 => 4.2.0 gatsby-plugin-sharp: ^3.2.0 => 3.2.0 gatsby-plugin-tsconfig-paths: ^1.0.2 => 1.0.2 gatsby-plugin-typescript: ^3.2.0 => 3.2.0 gatsby-source-filesystem: ^3.2.0 => 3.2.0 gatsby-source-wordpress: ^5.4.0 => 5.4.1 gatsby-transformer-sharp: ^3.2.0 => 3.2.0

gustavo-a commented 3 years ago

Just found out that I was using a query with the same name as a fragment. It took me a couple of hours to figure that out.

Maybe we could do something to get better error handling in such cases?