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.

Hot-reload isn't working with .mdx files

See original GitHub issue

Description

Whenever running gatsby develop, it runs perfectly on the first try and hot-reloads the content if I’m updating page files or other components (.ts or .tsx files). However, if I try to update an .mdx file, the process just hangs in the “Re-building development bundle” step; if i add the --verbose tag when running gatsby develop, it hangs on “Transition to recompiling” indefinitely. Only by cancelling the rebuild process and starting it again I can see the rebuilt content.

Steps to reproduce

  1. Run Gatsby Develop
  2. Wait for the bundle to finish building and for the server to fully load
  3. Make a change to a .mdx file

Expected result

The development server should rebuild the development bundle and update the page content accordingly.

Actual result

The process hangs in the Transition to Recompiling step during the rebuild. If running Gatsby develop with verbose on, the log is the following:

verbose Webpack file changed: /Users/danielpereira/Documents/gatsby-project/src/docs/users/index.mdx
verbose Transition to "waiting" > "aggregatingFileChanges"
verbose Transition to "waiting" > "batchingNodeMutations"
verbose Transition to "waiting" > "committingBatch"
verbose Transition to "waiting" > "rebuild"
verbose Transition to "recreatingPages"
success building schema - 0.262s
verbose Transition to "recreatingPages" > "creatingPages"
info Total nodes: 119, SitePage nodes: 13 (use --verbose for breakdown)
verbose Number of node types: 9. Nodes per type: SitePage: 13, SitePlugin: 48, Site: 1, SiteBuildMetadata: 1, Directory: 13, File: 29, ImageSharp: 7, HomepageJson: 2, Mdx: 5
success createPages - 0.010s
verbose Checking for deleted pages
verbose Deleted 0 pages
verbose Found 0 changed pages
success Checking for changed pages - 0.003s
verbose Transition to "recreatingPages" > "rebuildingSchemaWithSitePage"
success update schema - 0.028s
verbose Transition to "recreatingPages" > "done"
verbose Transition to "runningQueries"
success onPreExtractQueries - 0.003s
success extract queries from components - 0.097s
verbose Transition to "runningQueries" > "waitingPendingQueries"
verbose Transition to "runningQueries" > "writingRequires"
success write out requires - 0.004s
verbose Transition to "runningQueries" > "calculatingDirtyQueries"
verbose Transition to "runningQueries" > "runningStaticQueries"
verbose Transition to "runningQueries" > "runningPageQueries"
verbose Transition to "runningQueries" > "waitingForJobs"
verbose Transition to "runningQueries" > "done"
verbose Transition to "recompiling"
not finished Re-building development bundle - 409.860s

Environment

System: OS: macOS 10.15.6 CPU: (8) x64 Intel® Core™ i7-4770HQ CPU @ 2.20GHz Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm Languages: Python: 3.8.3 - /Users/danielpereira/.pyenv/shims/python Browsers: Chrome: 86.0.4240.198 Firefox: 81.0.2 Safari: 13.1.2 npmPackages: gatsby: ^2.24.57 => 2.26.1 gatsby-alias-imports: ^1.0.4 => 1.0.6 gatsby-image: ^2.2.44 => 2.5.0 gatsby-plugin-emotion: ^4.2.0 => 4.4.0 gatsby-plugin-eslint: ^2.0.8 => 2.0.8 gatsby-plugin-google-analytics: ^2.3.14 => 2.5.0 gatsby-plugin-google-marketing-platform: ^0.1.21 => 0.1.21 gatsby-plugin-google-tagmanager: ^2.3.12 => 2.5.0 gatsby-plugin-manifest: ^2.2.48 => 2.6.0 gatsby-plugin-mdx: ^1.2.47 => 1.4.0 gatsby-plugin-offline: ^3.0.41 => 3.4.0 gatsby-plugin-preload-fonts: ^1.2.2 => 1.3.0 gatsby-plugin-react-helmet: ^3.1.24 => 3.4.0 gatsby-plugin-react-svg: ^3.0.0 => 3.0.0 gatsby-plugin-robots-txt: ^1.5.1 => 1.5.3 gatsby-plugin-sass: ^2.2.1 => 2.5.1 gatsby-plugin-sharp: ^2.6.3 => 2.8.0 gatsby-plugin-sitemap: ^2.4.12 => 2.6.0 gatsby-plugin-stylelint: ^3.2.0 => 3.2.0 gatsby-plugin-tslint: ^0.0.2 => 0.0.2 gatsby-plugin-typescript: ^2.3.1 => 2.6.0 gatsby-plugin-typescript-checker: ^1.1.1 => 1.1.1 gatsby-source-filesystem: ^2.3.35 => 2.5.0 gatsby-transformer-json: ^2.3.1 => 2.5.0 gatsby-transformer-remark: ^2.7.1 => 2.10.0 gatsby-transformer-sharp: ^2.3.19 => 2.6.0

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
KyleAMathewscommented, Dec 3, 2020

I was able to reproduce this (including when upgrading to 2.28). It seems like there’s an infinite loop in your code somewhere which gets triggered on re-compilation. There’s a lot of code in your reproduction so it’s hard to know for sure if it’s something in your code or it’s a gatsby/gatsby-plugin-mdx problem. Could you please remove all code from the reproduction that isn’t directly related to triggering the problem? Ideally a reproduction only has 1-2 files in it.

0reactions
LekoArtscommented, Mar 8, 2021

I’m closing this in favor of https://github.com/gatsbyjs/gatsby/issues/30062 as this issue here hasn’t got a minimal reproduction and the behavior might have changed with Gatsby v3.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hot reload not working for MDX files #16336 - gatsbyjs/gatsby
After a quick glance I believe it might be due to the fact that you are passing the MDX body to your template....
Read more >
Gatsby Hot Reload not working with MDX - Rysolv
Hot reload / browser refresh does not work with basic MDX setup. Steps to reproduce. Clone repo gatsby-minimal-mdx-hot-reload-bug-reproduction.
Read more >
Hot Reload MDX changes in Next.js and Nx
The common behavior is to auto-refresh the page whenever something in the markdown (MDX) content changes. While this works for our Next. js...
Read more >
Gatsby — Hot reload not working with .MDX generated pages
Issue. Gatsby hot reloading is not working when modifying CSS properties from Components that lives in generated .MDX pages.
Read more >
Add Fast Refresh Support to our MDX Files with Nx Support ...
However, you might notice that whenever we change something within our MDX markdown files, fast refresh is not capturing that, hence we need...
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