Gatsby returning error page for SSR page, works locally but not on netlify

I have worked with SSR before but with this current project for some reason the SSR pages aren’t working.
Everything builds ok, and I have updated the essentials Gatsby plugin along with installing and configuring the gatsby-plugin-netlify. I am using Gatsby 4.18.1.

I’ve read that it’s possible one of the dependencies could be preventing the SSR pages from being generated.

Any other steps I can take to debug this? Thanks

4:28:35 PM Preparing Gatsby filesystem
4:28:35 PM Starting to prepare data directory
4:28:35 PM Start copying data
4:28:35 PM End copying data
4:28:37 PM error Invoke Error 	{"errorType":"TypeError","errorMessage":"Cannot destructure property 'readFile' of 'fs_1.promises' as it is undefined.","stack":["TypeError: Cannot destructure property 'readFile' of 'fs_1.promises' as it is undefined.","    at Object.defineProperty.value (/var/task/web/.cache/query-engine/index.js:155042:9)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.defineProperty.value (/var/task/web/.cache/query-engine/index.js:146124:23)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.exports.__esModule (/var/task/web/.cache/query-engine/index.js:146001:18)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.<anonymous> (/var/task/web/.cache/query-engine/index.js:145544:12)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.<anonymous> (/var/task/web/.cache/query-engine/index.js:145505:47)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)"]}
4:28:37 PM c5f31b30 Duration: 2134.32 ms	Memory Usage: 279 MB	Init Duration: 763.36 ms
4:28:59 PM Preparing Gatsby filesystem
4:28:59 PM Starting to prepare data directory
4:28:59 PM directory already exists
4:29:00 PM error Invoke Error 	{"errorType":"TypeError","errorMessage":"Cannot destructure property 'readFile' of 'fs_1.promises' as it is undefined.","stack":["TypeError: Cannot destructure property 'readFile' of 'fs_1.promises' as it is undefined.","    at Object.defineProperty.value (/var/task/web/.cache/query-engine/index.js:155042:9)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.defineProperty.value (/var/task/web/.cache/query-engine/index.js:146124:23)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.exports.__esModule (/var/task/web/.cache/query-engine/index.js:146001:18)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.<anonymous> (/var/task/web/.cache/query-engine/index.js:145544:12)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.<anonymous> (/var/task/web/.cache/query-engine/index.js:145505:47)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)"]}
4:29:00 PM 4466115e Duration: 1674.97 ms	Memory Usage: 374 MB
4:29:02 PM Preparing Gatsby filesystem
4:29:02 PM Starting to prepare data directory
4:29:02 PM directory already exists
4:29:03 PM error Invoke Error 	{"errorType":"TypeError","errorMessage":"Cannot destructure property 'readFile' of 'fs_1.promises' as it is undefined.","stack":["TypeError: Cannot destructure property 'readFile' of 'fs_1.promises' as it is undefined.","    at Object.defineProperty.value (/var/task/web/.cache/query-engine/index.js:155042:9)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.defineProperty.value (/var/task/web/.cache/query-engine/index.js:146124:23)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.exports.__esModule (/var/task/web/.cache/query-engine/index.js:146001:18)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.<anonymous> (/var/task/web/.cache/query-engine/index.js:145544:12)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.<anonymous> (/var/task/web/.cache/query-engine/index.js:145505:47)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)"]}
4:29:03 PM c3207463 Duration: 1535.35 ms	Memory Usage: 453 MB
4:32:28 PM Preparing Gatsby filesystem
4:32:28 PM Starting to prepare data directory
4:32:28 PM directory already exists
4:32:30 PM error Invoke Error 	{"errorType":"TypeError","errorMessage":"Cannot destructure property 'readFile' of 'fs_1.promises' as it is undefined.","stack":["TypeError: Cannot destructure property 'readFile' of 'fs_1.promises' as it is undefined.","    at Object.defineProperty.value (/var/task/web/.cache/query-engine/index.js:155042:9)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.defineProperty.value (/var/task/web/.cache/query-engine/index.js:146124:23)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.exports.__esModule (/var/task/web/.cache/query-engine/index.js:146001:18)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.<anonymous> (/var/task/web/.cache/query-engine/index.js:145544:12)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)","    at Object.<anonymous> (/var/task/web/.cache/query-engine/index.js:145505:47)","    at __webpack_require__ (/var/task/web/.cache/query-engine/index.js:440228:42)"]}
4:32:30 PM 3bf6a1c4 Duration: 2234.96 ms	Memory Usage: 498 MB

A follow-up, I have a simpler project that’s almost a barebones of this: Create Portfolio with Gatsby | Sanity.io

Getting this using the SSR example on gatsby.

Hey @adamatronix,

Can you try using Gatsby@4.18.1 and netlify/plugin-gatsby@3.2.5 to see if it works?

Is 3.2.5 the newest? If so then this I the combo I am rolling. I installed the plugin via the netlify gui.

Actually I may not be on 4.18.1. I will double check.

Ok using GitHub - gatsbyjs/gatsby-starter-default: The default Gatsby starter as a test. It has the same issue.

Hey guys I’ve got the same issue when trying to defer some pages. Once I try to open them I get this.

This seems to be resolved as far as version 3.3.1 of the plugin is concerned. Which one are you using @oneclickgab ?

3.3.1, It doesn’t seem to be an issue with Netlify, I think it’s how Gatsby is handling image. Once I started using the source URL from images it got fixed, however on cold starts this DSR function throws an error I can share. It seems that it doesn’t find a directory? But if I try right after it works.

Try updating to the latest version of Node 16??

It’s using node v16.16.0 :frowning:

I’m sorry. I’m still using Gatsby v3 w/the newest netlify plugin that will work with that. It was 3.14 last time I checked so this seems to be an issue w/Gatsby 4. I wanted to migrate so if I have time I will try to help

I just wanted to point out that it can’t mkdir there which means that the parent directory structure also doesn’t exist. So that source plugin doesn’t seem to support doing things on a Netlify build server. (I think) Otherwise mkdir -p would work if it has write access in the root.

Hey there, @oneclickgab :wave:

Can you please share a link to your site and repository? This will help us investigate this issue further. Thank you!