question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Gatsby develop leaves .cache/json empty from version 2.24.12

See original GitHub issue

Description

I cannot use the gatsby develop command because it leaves an empty .cache/json folder thus the dev server cannot serve the site.

Unforunately the codebase is private but I was able identify on which gatsby version the issue occured. Gatsby 2.24.8 and 2.24.10 => OK develop works normally Gatsby 2.24.9 and 2.24.11 => develop works but output non blocking errors at the end of the script :

Error loading a result for the page query in "/dev-404-page". Query was not run and no cached result was found.
Error loading a result for the page query in "/404.html". Query was not run and no cached result was found.
Error loading a result for the page query in "/". Query was not run and no cached result was found.

From Gatsby 2.24.12 to current version 2.24.34 (I didn’t test every version in between) =>.cache/json stays empty during develop script. This is the last output before crash :

success Building development bundle - 55.715s

ERROR 

ENOENT: no such file or directory, open '/Users/path/to/project/.cache/json/_...random..._page.json'

Steps to reproduce

Run gatsby develop

Expected result

The develop script run smoothly and and development server is launched at the end of the process

Actual result

The develop script runs without apparent errors but then the dev server crashes because .cache/json is empty

Environment

  System:
    OS: macOS 10.15.6
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 14.4.0 - ~/.nvm/versions/node/v14.4.0/bin/node
    Yarn: 1.22.4 - ~/.yarn/bin/yarn
    npm: 6.14.5 - ~/.nvm/versions/node/v14.4.0/bin/npm
  Languages:
    Python: 2.7.16 - /usr/bin/python
  Browsers:
    Chrome: 84.0.4147.105
    Firefox: 79.0
    Safari: 13.1.2
  npmPackages:
    gatsby: ^2.24.34 => 2.24.34 
    gatsby-background-image: ^1.1.1 => 1.1.1 
    gatsby-image: ^2.4.14 => 2.4.14 
    gatsby-plugin-eslint: ^2.0.8 => 2.0.8 
    gatsby-plugin-google-tagmanager: ^2.3.11 => 2.3.11 
    gatsby-plugin-manifest: ^2.4.22 => 2.4.22 
    gatsby-plugin-material-ui: ^2.1.10 => 2.1.10 
    gatsby-plugin-node-reload: ^1.1.0 => 1.1.0 
    gatsby-plugin-offline: ^3.2.22 => 3.2.22 
    gatsby-plugin-react-helmet: ^3.3.10 => 3.3.10 
    gatsby-plugin-react-leaflet: ^2.0.13 => 2.0.13 
    gatsby-plugin-remote-images: ^2.2.0 => 2.2.0 
    gatsby-plugin-s3: ^0.3.3 => 0.3.4 
    gatsby-plugin-sass: ^2.3.12 => 2.3.12 
    gatsby-plugin-sharp: ^2.6.25 => 2.6.25 
    gatsby-plugin-typegen: ^2.2.1 => 2.2.1 
    gatsby-plugin-typescript: ^2.4.15 => 2.4.17 
    gatsby-plugin-typescript-checker: ^1.1.1 => 1.1.1 
    gatsby-source-filesystem: ^2.3.24 => 2.3.24 
    gatsby-source-graphql: ^2.7.0 => 2.7.0 
    gatsby-transformer-sharp: ^2.5.12 => 2.5.12 
  npmGlobalPackages:
    gatsby-cli: 2.12.77

Dependencies

"dependencies": {
    "@date-io/date-fns": "^1.3.13",
    "@material-ui/core": "^4.10.2",
    "@material-ui/icons": "^4.9.1",
    "@material-ui/lab": "^4.0.0-alpha.56",
    "@material-ui/pickers": "^3.2.10",
    "@react-hook/throttle": "^2.2.0",
    "axios": "^0.19.2",
    "babel-preset-react-app": "^9.1.1",
    "classnames": "^2.2.6",
    "date-fns": "^2.15.0",
    "date-fns-timezone": "^0.1.4",
    "deepmerge": "^4.2.2",
    "dompurify": "^2.0.11",
    "elasticsearch-browser": "^16.7.1",
    "gatsby": "^2.24.34",
    "gatsby-background-image": "^1.1.1",
    "gatsby-image": "^2.4.14",
    "gatsby-plugin-google-tagmanager": "^2.3.11",
    "gatsby-plugin-manifest": "^2.4.22",
    "gatsby-plugin-material-ui": "^2.1.10",
    "gatsby-plugin-node-reload": "^1.1.0",
    "gatsby-plugin-offline": "^3.2.22",
    "gatsby-plugin-react-helmet": "^3.3.10",
    "gatsby-plugin-react-leaflet": "^2.0.13",
    "gatsby-plugin-remote-images": "^2.2.0",
    "gatsby-plugin-s3": "^0.3.3",
    "gatsby-plugin-sass": "^2.3.12",
    "gatsby-plugin-sharp": "^2.6.25",
    "gatsby-plugin-typegen": "^2.2.1",
    "gatsby-plugin-typescript": "^2.4.15",
    "gatsby-plugin-typescript-checker": "^1.1.1",
    "gatsby-source-filesystem": "^2.3.24",
    "gatsby-source-graphql": "^2.7.0",
    "gatsby-transformer-sharp": "^2.5.12",
    "leaflet": "^1.6.0",
    "node-sass": "^4.14.1",
    "react": "^16.13.0",
    "react-dom": "^16.13.0",
    "react-helmet": "^6.1.0",
    "react-intl": "^5.4.6",
    "react-leaflet": "^2.7.0",
    "react-player": "^2.5.0",
    "slugify": "^1.4.5",
    "yup": "^0.29.3"
},
"devDependencies": {
    "@formatjs/cli": "^2.3.1",
    "@octokit/core": "^3.1.2",
    "@octokit/plugin-retry": "^3.0.3",
    "@octokit/rest": "^18.0.1",
    "@storybook/addon-actions": "^5.3.19",
    "@storybook/addon-info": "^5.3.19",
    "@storybook/addon-knobs": "^5.3.19",
    "@storybook/addon-links": "^5.3.19",
    "@storybook/addon-viewport": "^5.3.19",
    "@storybook/addons": "^5.3.19",
    "@storybook/react": "^5.3.19",
    "@types/classnames": "^2.2.10",
    "@types/dompurify": "^2.0.3",
    "@types/geojson": "^7946.0.7",
    "@types/jest": "^26.0.9",
    "@types/leaflet": "^1.5.16",
    "@types/react": "^16.9.44",
    "@types/react-dom": "^16.9.7",
    "@types/react-helmet": "^6.1.0",
    "@types/react-leaflet": "^2.5.1",
    "@types/yup": "^0.29.4",
    "@typescript-eslint/eslint-plugin": "^3.8.0",
    "babel-loader": "^8.0.6",
    "env-cmd": "^10.1.0",
    "eslint": "^7.6.0",
    "eslint-config-airbnb-typescript": "^9.0.0",
    "eslint-config-prettier": "^6.11.0",
    "eslint-loader": "^4.0.2",
    "eslint-plugin-import": "^2.21.2",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-prettier": "^3.1.4",
    "eslint-plugin-react": "^7.20.5",
    "eslint-plugin-react-hooks": "^4.0.8",
    "gatsby-plugin-eslint": "^2.0.8",
    "husky": "^4.2.3",
    "lint-staged": "^10.2.11",
    "minimist": "^1.2.3",
    "prettier": "^2.0.5",
    "shelljs": "^0.8.4",
    "typescript": "^3.9.7"
},

Gatsby-Config

const activeEnv = process.env.GATSBY_ACTIVE_ENV || process.env.NODE_ENV || 'development';
require('dotenv').config({
    path: `.env.${activeEnv}`,
});

module.exports = {
    pathPrefix: '', // CircleCi Artifacts prefix
    assetPrefix: process.env.ASSET_PREFIX_URL,
    siteMetadata: {
        title: 'title',
        description: 'description',
        author: '@autho',
    },
    plugins: [
        {
            resolve: 'gatsby-plugin-google-tagmanager',
            options: {
                id: process.env.GATSBY_GTM_ID,
                includeInDevelopment: true,
            },
        },
        'gatsby-plugin-typescript',
        'gatsby-plugin-typescript-checker',
        'gatsby-plugin-node-reload',
        {
            resolve: 'gatsby-plugin-typegen',
            options: {
                emitSchema: {
                    'src/__generated__/gatsby-introspection.json': true,
                    'src/__generated__/gatsby-schema.graphql': true,
                },
                emitPluginDocuments: {
                    'src/__generated__/gatsby-plugin-documents.graphql': true,
                },
            },
        },
        {
            resolve: 'gatsby-source-graphql',
            options: {
                // Arbitrary name for the remote schema Query type
                typeName: 'GATEWAY',
                // Field under which the remote schema will be accessible. You'll use this in your Gatsby query
                fieldName: 'gateway',
                // Url to query from
                url: process.env.GATSBY_GRAPHQL_API,
            },
        },
        {
            resolve: 'gatsby-plugin-react-leaflet',
            options: {
                linkStyles: true, // (default: true) Enable/disable loading stylesheets via CDN
            },
        },
        {
            resolve: 'gatsby-plugin-eslint',
            options: {
                test: /\.js$|\.jsx$|\.ts$|\.tsx$/,
                exclude: /(node_modules|.cache|public)/,
                stages: ['develop'],
                options: {
                    emitWarning: true,
                    failOnError: true,
                },
            },
        },
        'gatsby-plugin-sass',
        'gatsby-plugin-react-helmet',
        'gatsby-plugin-material-ui-theme-provider', // Custom Plugin
        {
            resolve: 'gatsby-plugin-material-ui',
            options: {
                stylesProvider: {
                    injectFirst: true,
                },
            },
        },
        {
            resolve: 'gatsby-source-s3-asset',
            options: {
                accessKeyId: process.env.GATSBY_AWS_ACCESS_KEY,
                secretAccessKey: process.env.GATSBY_AWS_SECRET_ACCESS_KEY,
                region: process.env.GATSBY_AWS_REGION,
                bucketName: process.env.GATSBY_ASSETS_BUCKET_NAME,
                publicDomain: process.env.GATSBY_ASSETS_BUCKET_NAME,
                protocol: 'https',
                prefix: 'common',
                nodeType: 'Assets',
            },
        },
        {
            resolve: 'gatsby-plugin-s3',
            options: {
                bucketName: 'staging.domain.com',
                protocol: 'https',
                hostname: 'staging.domain.fr',
            },
        },
        {
            resolve: 'gatsby-plugin-remote-images',
            options: {
                nodeType: 'Assets',
                imagePath: 'url',
                prepareUrl: (url) => encodeURI(url),
            },
        },
        'gatsby-transformer-sharp',
        'gatsby-plugin-sharp',
        {
            resolve: 'gatsby-plugin-manifest',
            options: {
                name: 'name',
                short_name: 'short_name',
                start_url: '/',
                background_color: '#252733',
                theme_color: '#29c5a9',
                display: 'minimal-ui',
                icon: 'src/images/icon.png', // This path is relative to the root of the site.
            },
        },
    ],
};

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:5
  • Comments:10 (7 by maintainers)

github_iconTop GitHub Comments

7reactions
wardpeetcommented, Sep 16, 2020

So the issue is that gatsby-plugin-typegen writes files into the src director during query running.

While we have calculated which queries to run after staticQueries we get back into extractingQuery state and calculateDirtyQueries will not give us the correct information anymore so it looks like we have 0 pageQueries to run

Gatsby develop log
$ yarn develop --verbose
yarn run v1.22.4
warning ..\package.json: No license field
$ gatsby develop -H 0.0.0.0 --verbose
verbose set gatsby_log_level: "verbose"
verbose set gatsby_executing_command: "develop"
verbose loading local command from:
verbose running command: develop
verbose Transition to "initializing"
success open and validate gatsby-configs - 0.550s
success load plugins - 1.526s
success onPreInit - 0.030s
success initialize cache - 0.006s
success copy gatsby files - 0.060s
verbose [typegen] Successfully validate your configuration.
{
  "language": "typescript",
  "namespace": "GatsbyTypes",
  "outputPath": "src/__generated__/gatsby-types.d.ts",
  "includeResolvers": false,
  "autoFix": true,
  "emitSchema": {},
  "emitPluginDocuments": {},
  "scalars": {}
}
verbose [typegen] Listen on query extraction
success onPreBootstrap - 0.027s
verbose Transition to "initializingData"
success createSchemaCustomization - 0.014s
verbose Transition to "initializingData" > "sourcingNodes"
warn Unable to fetch firebase data for awards due to error code undefined. Using dummy data instead.
verbose Now have 99 nodes with 8 types: [SitePage:1, SitePlugin:35, Site:1, SiteBuildMetadata:1, Directory:5,      
verbose Checking for deleted pages
verbose Deleted 0 pages
verbose Found 0 changed pages
success Checking for changed pages - 0.007s
success source and transform nodes - 0.213s
verbose Transition to "initializingData" > "buildingSchema"
warn Deprecation warning - adding inferred resolver for field ConferenceAwardsData.time. In Gatsby v3, only fields
success building schema - 0.353s
verbose Transition to "initializingData" > "creatingPages"
verbose Now have 99 nodes with 8 types, and 1 SitePage nodes
success createPages - 0.006s
verbose Checking for deleted pages
verbose Deleted 0 pages
verbose Found 0 changed pages
success Checking for changed pages - 0.003s
verbose Transition to "initializingData" > "creatingPagesStatefully"
success createPagesStatefully - 0.209s
verbose Transition to "initializingData" > "rebuildingSchemaWithSitePage"
success update schema - 0.017s
verbose Transition to "initializingData" > "writingOutRedirects"
success write out redirect data - 0.004s
verbose Transition to "initializingData" > "done"
verbose Transition to "runningPostBootstrap"
success Build manifest and related icons - 0.142s
verbose [typegen] End-up listening on query extraction.
verbose [typegen] Watching schema/query changes and re-run workers
verbose [typegen] Generate type definitions to src/__generated__/gatsby-types.d.ts. (language: TypeScript)
success onPostBootstrap - 0.275s
info bootstrap finished - 5.942s
verbose Transition to "runningQueries"
success onPreExtractQueries - 0.003s
success extract queries from components - 0.428s
verbose Transition to "runningQueries" > "writingRequires"
success write out requires - 0.055s
calculate [
  '/dev-404-page/',
  '/404/',
  '/awards/',
  '/calendar/',
  '/conferences/',
  '/dashboard/',
  '/home-old/',
  '/',
  '/kennedy/',
  '/resources/',
  '/secretariat/',
  '/account/create/',
  '/account/',
  '/account/login/',
  '/account/logout/',
  '/account/recover/',
  '/account/send-email-verification/',
  '/account/settings/',
  '/admin/awards/',
  '/admin/edit-member-dashboard/',
  '/admin/',
  '/admin/members/',
  '/admin/synchronize-claims/',
  '/account/email-action/confirm-email-change/',
  '/account/email-action/handle/',
  '/account/email-action/recover-email/',
  '/account/email-action/reset-password/',
  '/account/email-action/verify-email/',
  '/conferences/bmun/register/',
  '/404.html',
  'sq--src-components-index-hero-tsx',
  'sq--src-components-index-about-tsx',
  'sq--src-components-index-hero-video-tsx',
  'sq--src-components-layout-auth-layout-tsx',
  'sq--src-components-layout-navbar-tsx',
  'sq--src-components-layout-seo-tsx',
  'sq--src-pages-awards-tsx'
]
{
  page: [
    '/dev-404-page/',
    '/404/',
    '/awards/',
    '/calendar/',
    '/conferences/',
    '/dashboard/',
    '/home-old/',
    '/',
    '/kennedy/',
    '/resources/',
    '/secretariat/',
    '/account/create/',
    '/account/',
    '/account/login/',
    '/account/logout/',
    '/account/recover/',
    '/account/send-email-verification/',
    '/account/settings/',
    '/admin/awards/',
    '/admin/edit-member-dashboard/',
    '/admin/',
    '/admin/members/',
    '/admin/synchronize-claims/',
    '/account/email-action/confirm-email-change/',
    '/account/email-action/handle/',
    '/account/email-action/recover-email/',
    '/account/email-action/reset-password/',
    '/account/email-action/verify-email/',
    '/conferences/bmun/register/',
    '/404.html'
  ],
  static: [
    'sq--src-components-index-hero-tsx',
    'sq--src-components-index-about-tsx',
    'sq--src-components-index-hero-video-tsx',
    'sq--src-components-layout-auth-layout-tsx',
    'sq--src-components-layout-navbar-tsx',
    'sq--src-components-layout-seo-tsx',
    'sq--src-pages-awards-tsx'
  ]
}
verbose Transition to "runningQueries" > "calculatingDirtyQueries"
runStaticQueries [
  'sq--src-components-index-hero-tsx',
  'sq--src-components-index-about-tsx',
  'sq--src-components-index-hero-video-tsx',
  'sq--src-components-layout-auth-layout-tsx',
  'sq--src-components-layout-navbar-tsx',
  'sq--src-components-layout-seo-tsx',
  'sq--src-pages-awards-tsx'
]
verbose Transition to "runningQueries" > "runningStaticQueries"
verbose [typegen] Generate type definitions to src/__generated__/gatsby-types.d.ts. (language: TypeScript)
verbose Transition to "runningQueries" > "extractingQueries"
success onPreExtractQueries - 0.009s
success onPreExtractQueries - 0.005s
success extract queries from components - 0.064s
verbose Transition to "runningQueries" > "writingRequires"
success write out requires - 0.008s
calculate []
{}
verbose Transition to "runningQueries" > "calculatingDirtyQueries"
verbose Transition to "runningQueries" > "runningStaticQueries"
runPageQueries []
0
verbose Transition to "runningQueries" > "runningPageQueries"
verbose Transition to "runningQueries" > "waitingForJobs"
success run static queries - 0.826s - 7/7 8.48/s
verbose [typegen] Generate type definitions to src/__generated__/gatsby-types.d.ts. (language: TypeScript)
verbose Transition to "runningQueries" > "extractingQueries"
success onPreExtractQueries - 0.007s
success onPreExtractQueries - 0.005s
success extract queries from components - 0.062s
verbose Transition to "runningQueries" > "writingRequires"
success write out requires - 0.005s
calculate []
{}
verbose Transition to "runningQueries" > "calculatingDirtyQueries"
verbose Transition to "runningQueries" > "runningStaticQueries"
runPageQueries []
0
verbose Transition to "runningQueries" > "runningPageQueries"
verbose Transition to "runningQueries" > "waitingForJobs"
verbose Transition to "runningQueries" > "done"
verbose Transition to "startingDevServers"
success Generating image thumbnails - 11.374s - 53/53 4.66/s
warn ⠀
warn risk - There are upcoming breaking changes: removeDeprecatedGapUtilities, purgeLayersByDefault
warn risk - We highly recommend opting-in to these changes now to simplify upgrading Tailwind in the future.       
warn risk - https://tailwindcss.com/docs/upcoming-changes
⠀
You can now view montavistamun in the browser.
⠀
  Local:            http://localhost:8000/
  On Your Network:  http://10.8.0.1:8000/
⠀
View GraphiQL, an in-browser IDE, to explore your site's data and schema
⠀
  Local:            http://localhost:8000/___graphql
  On Your Network:  http://10.8.0.1:8000/___graphql
⠀
Note that the development build is not optimized.
To create a production build, use gatsby build
⠀
warn ESLintError:
C:\Users\Ward\projects\gatsby\tmp\montavistamun\gatsby-browser.js
  12:32  warning  Missing return type on function          @typescript-eslint/explicit-module-boundary-types       
  12:33  warning  Object pattern argument should be typed  @typescript-eslint/explicit-module-boundary-types       

✖ 2 problems (0 errors, 2 warnings)

success Building development bundle - 20.830s
verbose Transition to "waiting"

 ERROR 

ENOENT: no such file or directory, open 'C:\Users\Ward\projects\gatsby\tmp\montavistamun\.cache\json\_dev-404-page_.json'



  Error: ENOENT: no such file or directory, open 'C:\Users\Ward\projects\gatsby\tmp\montavistamun\.cache\json\_dev-  404-page_.json'

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
4reactions
wardpeetcommented, Sep 18, 2020

Successfully published:

  • gatsby@2.24.63
Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging Cache Issues - Gatsby
consider utilizing the gatsby clean command which can help resolve caching issues for you. First make sure the version of gatsby specified in...
Read more >
gatsby | Yarn - Package Manager
Gatsby is a free and open source framework based on React that helps developers build blazing fast websites and apps. It combines the...
Read more >
gatsby/CHANGELOG.md - UNPKG
The CDN for gatsby.
Read more >
Files changed (172) - Renovate Bot Package Diff
// errors within the console, such as when exiting the develop process. cache-dir/commonjs/gatsby-browser-entry.
Read more >
Gatsby - The result of this StaticQuery could not be fetched
Then clear Gatsby cache and restart the server. ... package.json "storybook:static-query": "yarn clean && yarn build && cp -r .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found