SSR is not working properly gatsby project

Hi, I’m trying to deploy a Gatsby site using SSR. In development mode, it works but in production, I’m having this:
On the home page after deployment:

{
  "errorMessage": "RequestId: 17a104fc-1a1f-482a-87cb-68f2826abc31 Error: Runtime exited with error: exit status 1",
  "errorType": "Runtime.ExitError"
}

I installed the Essential Gatsby plugin and on the functions logs I have this:

10:31:24 PM 2021-12-07T04:31:24.553Z	undefined	INFO	Start copying data
10:31:24 PM 2021-12-07T04:31:24.564Z	undefined	INFO	End copying data
10:31:24 PM 2021-12-07T04:31:24.830Z	undefined	INFO	could not write to cache directory, please make sure the following path exists and is writable
10:31:24 PM 2021-12-07T04:31:24.830Z	undefined	INFO	  /var/task
10:31:24 PM 2021-12-07T04:31:24.833Z	undefined	ERROR	Error: EROFS: read-only file system, access '/var/task'
    at Object.accessSync (fs.js:228:3)
    at Object.3645 (/var/task/.cache/page-ssr/routes/render-page.js:4962:268)
    at __webpack_require__ (/var/task/.cache/page-ssr/routes/render-page.js:9650:41)
    at Object.1381 (/var/task/.cache/page-ssr/routes/render-page.js:4950:215)
    at __webpack_require__ (/var/task/.cache/page-ssr/routes/render-page.js:9650:41)
    at Object.9874 (/var/task/.cache/page-ssr/routes/render-page.js:4361:392)
    at __webpack_require__ (/var/task/.cache/page-ssr/routes/render-page.js:9650:41)
    at /var/task/.cache/page-ssr/routes/render-page.js:9775:491
    at /var/task/.cache/page-ssr/routes/render-page.js:9801:3
    at Object.<anonymous> (/var/task/.cache/page-ssr/routes/render-page.js:9806:12) {
  errno: -30,
  syscall: 'access',
  code: 'EROFS',
  path: '/var/task'
}
10:31:25 PM 2021-12-07T04:31:25.121Z	undefined	INFO	directory already exists
10:31:25 PM 2021-12-07T04:31:25.505Z	undefined	INFO	could not write to cache directory, please make sure the following path exists and is writable
10:31:25 PM 2021-12-07T04:31:25.505Z	undefined	INFO	  /var/task
10:31:25 PM 2021-12-07T04:31:25.508Z	undefined	ERROR	Error: EROFS: read-only file system, access '/var/task'
    at Object.accessSync (fs.js:228:3)
    at Object.3645 (/var/task/.cache/page-ssr/routes/render-page.js:4962:268)
    at __webpack_require__ (/var/task/.cache/page-ssr/routes/render-page.js:9650:41)
    at Object.1381 (/var/task/.cache/page-ssr/routes/render-page.js:4950:215)
    at __webpack_require__ (/var/task/.cache/page-ssr/routes/render-page.js:9650:41)
    at Object.9874 (/var/task/.cache/page-ssr/routes/render-page.js:4361:392)
    at __webpack_require__ (/var/task/.cache/page-ssr/routes/render-page.js:9650:41)
    at /var/task/.cache/page-ssr/routes/render-page.js:9775:491
    at /var/task/.cache/page-ssr/routes/render-page.js:9801:3
    at Object.<anonymous> (/var/task/.cache/page-ssr/routes/render-page.js:9806:12) {
  errno: -30,
  syscall: 'access',
  code: 'EROFS',
  path: '/var/task'
}
10:31:25 PM 17a104fc Duration: 618.18 ms	Memory Usage: 58 MB
10:31:25 PM RequestId: 17a104fc-1a1f-482a-87cb-68f2826abc31 Error: Runtime exited with error: exit status 1
Runtime.ExitError

I already added AWS_LAMBDA_JS_RUNTIME variable to nodejs14.x

Any idea what I’m doing wrong?

Hey there, @Angel :wave:

Sorry to hear you are encountering this issue. Can you please share a link to your site as well as your public repo? This will help us look into this further.

Hi, thanks for answering. The site link is performance.pixel506.com

Hi Angel, like I said above, we also need your repo. If you can’t share that, can you please create a test repo that reproduces this issue? Thank you :slight_smile:

Hi, sorry, here is the repo url: ssr-test repo
and here is the test site url: test site

Hi @Angel

The site deployed from this test repository does not (for me) return any errors. Both / and /ssr-page render correctly.

It would help if the test repository created the same error.

1 Like

Please try this one:
repo
site

Hi, did you see the repo?

Sorry for the delay here @Angel, I just tested your repo and deployed it without changing defaults and the site deployed fine:

https://eloquent-franklin-9b4e72.netlify.app/

I had a similar issue where I was experiencing a runtime error on SSR pages. After corresponding with support they narrowed down that gatsby-plugin-preload-fonts was the culprit. Removing that plugin solved my issue, and SSR pages are now successfully built.

1 Like

Thanks for coming back and sharing that, @rossbrown. Glad you found a solution that worked :netliconfetti: