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:

https://floridabulldogshockey.com/tournaments/mlk2022

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:

https://affectionate-cray-5edd1e.netlify.app/someroute/somepage

{ā€œ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 https://affectionate-cray-5edd1e.netlify.app/ 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 (https://affectionate-cray-5edd1e.netlify.app/someroute/somepage)

1 Like

That is great news! Thanks so much for confirming.

Happy building :netliconfetti:

1 Like