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

gatsby develop: page query hanging #26530

Closed
Biboswan opened this issue Aug 18, 2020 · 12 comments
Closed

gatsby develop: page query hanging #26530

Biboswan opened this issue Aug 18, 2020 · 12 comments
Assignees
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@Biboswan
Copy link

Biboswan commented Aug 18, 2020

open and validate gatsby-configs - 0.067s
success load plugins - 7.837s
warn The Google Analytics plugin requires a tracking ID. Did you mean to add it?
success onPreInit - 0.211s
success initialize cache - 0.024s
success copy gatsby files - 0.175s
warn gatsby-plugin-feed-mdx was initialized in gatsby-config.js without a feeds option.
This means that the plugin will use the internal RSS feed creation, which may not match your use case.
This behavior will be removed in the next major release of gatsby-plugin-feed.
For more info, check out: https://gatsby.dev/adding-rss-feed
success onPreBootstrap - 0.070s
success createSchemaCustomization - 0.017s
success Checking for changed pages - 0.003s
success source and transform nodes - 2.948s
success building schema - 0.567s
success createPages - 0.052s
success Checking for changed pages - 0.003s
success createPagesStatefully - 0.123s
success update schema - 0.042s
success write out redirect data - 0.002s
success Build manifest and related icons - 0.389s
success onPostBootstrap - 0.400s
info bootstrap finished - 24.749s
success onPreExtractQueries - 0.004s
success extract queries from components - 0.732s
success write out requires - 0.117s
success run static queries - 0.150s - 2/2 13.36/s
warn Query takes too long:
File path: /Volumes/MacStorage/bibo-demoblog/src/templates/blog-post.js
URL path: /blog/hello-world/
Context: {
    "slug": "/hello-world/",
    "previous": null,
    "next": {
        "fields": {
            "slug": "/my-second-post/"
        },
        "frontmatter": {
            "title": "My Second Post!"
        }
    }
}
warn Query takes too long:
File path: /Volumes/MacStorage/bibo-demoblog/src/pages/blog.js
URL path: /blog/
[============================]   17.683 s 13/13 100% Generating image thumbnails
[================            ]   17.569 s 6/10 60% run page queries

Tried gatsby clean, Updated gatsby from 2.24.37 to .2.24.47

module.exports = {
  siteMetadata: {
    title: `Bibo-gatsby-cms-demoblog`,
    author: `Biboswan98`,
    description: `A demo starter personal blog with styled components, dark mode, and Netlify CMS.`,
    siteUrl: `https://bibo-gatsby-cms-demoblog.netlify.com/`,
    social: {
      twitter: `Biboswan98`,
    },
  },
  plugins: [
    `gatsby-plugin-netlify-cms`,
    `gatsby-plugin-styled-components`,
    `gatsby-transformer-sharp`,
    `gatsby-plugin-sharp`,
    `gatsby-plugin-offline`,
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-feed-mdx`,
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/content/blog`,
        name: `blog`,
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        path: `${__dirname}/content/assets`,
        name: `assets`,
      },
    },
    {
      resolve: `gatsby-plugin-mdx`,
      options: {
        extensions: [".mdx", ".md"],
        gatsbyRemarkPlugins: [
          {
            resolve: `gatsby-remark-images`,
            options: {
              maxWidth: 590,
            },
          },
          {
            resolve: `gatsby-remark-responsive-iframe`,
            options: {
              wrapperStyle: `margin-bottom: 1.0725rem`,
            },
          },
          {
            resolve: `gatsby-remark-vscode`,
          },
          {
            resolve: `gatsby-remark-copy-linked-files`,
          },
          {
            resolve: `gatsby-remark-smartypants`,
          },
        ],
        plugins: [`gatsby-remark-images`],
      },
    },
    {
      resolve: `gatsby-plugin-google-analytics`,
      options: {
        // edit below
        // trackingId: `ADD YOUR TRACKING ID HERE`,
      },
    },
    {
      resolve: `gatsby-plugin-manifest`,
      options: {
        name: `Gatsby Starter Blog`,
        short_name: `GatsbyJS`,
        start_url: `/`,
        background_color: `#ffffff`,
        theme_color: `#663399`,
        display: `minimal-ui`,
        // edit below
        icon: `content/assets/favicon.png`,
      },
    },
    {
      resolve: `gatsby-plugin-typography`,
      options: {
        pathToConfigModule: `src/utils/typography`,
      },
    },
  ],
}

Node version: v10.16.3 (npm v6.9.0)
OS: MacSierra

@Biboswan Biboswan added the type: question or discussion Issue discussing or asking a question about Gatsby label Aug 18, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 18, 2020
@swkeever
Copy link

swkeever commented Aug 19, 2020

I'm also having this issue after updating Gatsby.

$ gatsby develop
Debugger listening on ws://127.0.0.1:9229/77471d58-d813-4521-8580-7f98cbf6f896
For help, see: https://nodejs.org/en/docs/inspector
success open and validate gatsby-configs - 0.147s
success load plugins - 0.447s
success onPreInit - 0.027s
success initialize cache - 0.006s
success copy gatsby files - 0.018s
success onPreBootstrap - 0.007s
success createSchemaCustomization - 0.006s
success Checking for changed pages - 0.002s
success source and transform nodes - 2.999s
success building schema - 0.288s
success createPages - 0.040s
success Checking for changed pages - 0.001s
success createPagesStatefully - 0.066s
success update schema - 0.020s
success write out redirect data - 0.002s
warn The icon(images/favicon.png) you provided to 'gatsby-plugin-manifest' is not square.
The icons we generate will be square and for the best results we recommend you provide a square
icon.
success Build manifest and related icons - 0.068s
success onPostBootstrap - 0.075s
info bootstrap finished - 5.507s
success onPreExtractQueries - 0.003s
success extract queries from components - 1.209s
success write out requires - 0.039s
warn Query takes too long:
File path: /home/sean/dev/gatsby-starter-default/src/pages/index.tsx
[============================]   18.762 s 135/135 100% Generating image thumbnails
[=========                   ]   15.019 s 1/3 33% run static queries

npm 6.14.8
OS: Ubuntu 18.04

Temporarily working around this issue by rolling back to Gatsby version 2.23.1

Steps to reproduce

git clone git@github.com:swkeever/skies.dev.git
cd skies.dev
npm update
npm install
npm run dev

@blainekasten
Copy link
Contributor

@sidharthachatterjee @freiksenet or @vladar, do you have any ideas?

@blainekasten blainekasten removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 25, 2020
@vladar
Copy link
Contributor

vladar commented Aug 26, 2020

@swkeever Can you please check what is the latest version where it works for you? Is it 2.23.1 or maybe it works on later versions as well? Basically we need to find a first versions that breaks.

@vladar
Copy link
Contributor

vladar commented Aug 26, 2020

A quick investigation shows that it is probably somehow related to MDX (not 100% sure yet though)

@vladar
Copy link
Contributor

vladar commented Aug 26, 2020

If I remove gatsby-remark-vscode plugin here develop works as expected.

There is a bug report in gatsby-remark-vscode: andrewbranch/gatsby-remark-vscode#115 which sounds pretty similar so I am going to close this issue and suggest to track it there.

@vladar vladar closed this as completed Aug 26, 2020
@swkeever
Copy link

Got it. Thank you for looking into this.

@vladar
Copy link
Contributor

vladar commented Aug 26, 2020

It could be actually caused by core changes. The referenced issue mentions that the problem was introduced in 2.24.9. If so, then this PR can be a culprit: #25479

I am going to re-open this issue until we confirm it's a plugin, not a core issue.

@vladar vladar reopened this Aug 26, 2020
@vladar
Copy link
Contributor

vladar commented Aug 26, 2020

What I've discovered so far:

  1. MDX calls remarkPlugins in custom resolver here

  2. As a part of this call VSCode plugin calls and awaits for createNode here

But since this createNode call occurs after the sourceNodes step is over those promises are never resolved and no nodes are created. So technically creating nodes inside the query running step is not an anticipated usage of Gatsby APIs. This was working before but broke after #25479

I am not sure yet what is the right course of action to fix this.

@pieh @ascorbic Any ideas?

@vladar
Copy link
Contributor

vladar commented Aug 26, 2020

Also, I guess the same issue will occur in any plugin calling createNode in query resolvers.

@vladar
Copy link
Contributor

vladar commented Aug 26, 2020

This PR was supposed to fix a similar issue: #26138 so maybe just need some follow up

@vladar vladar added status: inkteam assigned type: bug An issue or pull request relating to a bug in Gatsby and removed type: question or discussion Issue discussing or asking a question about Gatsby labels Aug 27, 2020
@vladar
Copy link
Contributor

vladar commented Aug 27, 2020

To recap: the problem is that any node mutations (createNode, deleteNode, etc) are now deferred until develop machine reaches the waiting state. But in this example, a custom resolver awaits when node mutation completes. It doesn't allow the query to finish and transition to waiting state. So it's a chicken and egg problem.

I don't have enough context on our state charts yet to fix this correctly. The only idea I have so far is to debounce the runMutationBatch call when we see ADD_NODE_MUTATION in runningQueries state.

@ascorbic
Copy link
Contributor

ascorbic commented Sep 9, 2020

I'm closing this because it should be fixed in the latest version. I have tested it with @swkeever 's site and confirmed that it now works.

If anybody is still having the problem with the latest verison of gatsby, please open a new ticket that includes the output from gatsby develop --verbose, with a link to a reproduction. Thanks everyone for the reports!

@ascorbic ascorbic closed this as completed Sep 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants