Gatsby V4 - issue loading dynamic routes

Running into a production deployment-only issue with my Gatsby v4 app (amazing-wiles-1918a6) where I seem to be able to navigate just fine to dynamic routes once I load my page from a non-dynamic route, but if I attempt to navigate directly TO a dynamic route, I get a 404 error and it throws off the rendering of my page.

Example production link currently experiencing the issue as of 12/8/2021 at 12:02AM EST:

I can navigate to this dynamic page just fine once the site loads from a normal route (you’ll see you can click on “Resources” then select the tournament where you are prompted to login, as opposed to being given a half-rendered/broken page).

I cloned the gatsby-starter-blog repository in an attempt to reproduce the issue in a repository I could make public, and am getting a new error trying to directly load dynamic routes:

{“errorType”:“Runtime.ImportModuleError”,“errorMessage”:“Error: Cannot find module ‘/var/task/.cache/page-ssr’\nRequire stack:\n- /var/task/.netlify/functions-internal/__dsg/__dsg.js\n- /var/task/__dsg.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js”,“trace”:[“Runtime.ImportModuleError: Error: Cannot find module ‘/var/task/.cache/page-ssr’”,“Require stack:”,"- /var/task/.netlify/functions-internal/__dsg/__dsg.js","- /var/task/__dsg.js","- /var/runtime/UserFunction.js","- /var/runtime/index.js"," at _loadUserApp (/var/runtime/UserFunction.js:202:13)"," at Object.module.exports.load (/var/runtime/UserFunction.js:242:17)"," at Object. (/var/runtime/index.js:43:30)"," at Module._compile (internal/modules/cjs/loader.js:1085:14)"," at Object.Module._extensions…js (internal/modules/cjs/loader.js:1114:10)"," at Module.load (internal/modules/cjs/loader.js:950:32)"," at Function.Module._load (internal/modules/cjs/loader.js:790:12)"," at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)"," at internal/main/run_main_module.js:17:47"]}

You’ll see you can navigate to the base page of and click the link for ‘someroute’ and the page loads fine.

I followed the necessary instructions here for using Gatsby v4 with Netlify:

Any attention on this from those of you much more familiar with the guts of Netlify and Gatsby than I am will be much appreciated :slight_smile:

Hey @djben,

The Netlify-Gatsby 4 integration is far from complete. The team prioritised Nextjs plugin development and that’s close to completion at the moment. Once that’s done, the team will switch to Gatsby plugin’s development which would solve the issues that you might be facing.

I’m not sure if both of your issues are caused by the plugin, but any issue that is caused by it, wold be eventually solved. Till then, it’s better to use Gatsby 3 or if you need Gatsby 4, you’d have to hold off from using dynamic routes.

Any updates to this? Gatsby V4 has been out for a few months now.

I’m getting the sense that Netlify+Gatsby is becoming a dead end :frowning:

You might be in luck. The plugin is probably going to be released in this week.

1 Like

Sounds good! If it doesn’t seem to help I can also try raising an issue in Github.

Hey there, @djben :wave:

Thanks for following up! You can read about the plugin release here: Releases · netlify/netlify-plugin-gatsby · GitHub

Let us know if this helps! If it doesn’t, we can bring this up with the plugin author this week.

It did help, woohoo! I updated to the releaseed version of the netlify plugin, and dynamic routes now render properly, readily seen by loading the dynamic route of my sample app mentioned above (

1 Like

That is great news! Thanks so much for confirming.

Happy building :netliconfetti:

1 Like