Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gatsby Server Rendering API does not work in neither Netlify nor Vercel #39225

Open
2 tasks done
richardnguyen99 opened this issue Feb 8, 2025 · 1 comment
Open
2 tasks done
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: bug An issue or pull request relating to a bug in Gatsby

Comments

@richardnguyen99
Copy link

Preliminary Checks

Description

I am currently building a simple blog with Gatsby using MDX. In local, everything runs fine. In production, there is no installation or building errors on both platforms. However, both crashes when navigating to a SSR page (using getServerData).

In Netlify, it provides an error about the installing and building sharp module. This only happens during runtime when navigating to the SSR page, not during dependency installation.

Error: 
Something went wrong installing the "sharp" module

libvips-cpp.so.42: cannot open shared object file: No such file or directory

Possible solutions:
- Install with verbose logging and look for errors: "npm install --ignore-scripts=false --foreground-scripts --verbose sharp"
- Install for the current linux-x64 runtime: "npm install --platform=linux --arch=x64 sharp"
- Consult the installation documentation: https://sharp.pixelplumbing.com/install
 ...

After searching on the internet, Netlify states its limitation that gatsby-transformer-sharp does not run properly during SSR environment in Netlify. So, I switched to hosting my images on Cloudinary as suggested. It does not work. The page still crashes with the same error even though I don't use any official image plugins from GatsbyJS

I thought it might be a problem from Netlify so I switched to Vercel with the same app source, including Cloudinary image service. Vercel is enable to render some first visits. But after an arbitrary amount of visits, it will crash and give a different error.

GET /blog/ 500
error Error: ENOENT: no such file or directory, mkdir '/var/task/.cache/caches/gatsby'
    at Object.mkdirSync (node:fs:1363:26)
    at module.exports.makeDirSync (/var/task/.cache/query-engine/index.js:8925:13)
    at GatsbyCacheLmdb.init (/var/task/.cache/query-engine/index.js:147:8)
    at getCache (/var/task/.cache/query-engine/index.js:97:8)
    at exports.__esModule (/var/task/.cache/query-engine/index.js:28:60)
    at __webpack_require__ (/var/task/.cache/query-engine/index.js:360880:42)
    at /var/task/.cache/query-engine/index.js:361051:1
    at /var/task/.cache/query-engine/index.js:361250:3
    at Object.<anonymous> (/var/task/.cache/query-engine/index.js:361255:12)
    at Module.<anonymous> (/opt/rust/bytecode.js:2:1435) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'mkdir',
  path: '/var/task/.cache/caches/gatsby'
}

I've been stuck to this SSR page like forever so any help would be great.

Reproduction Link

https://github.com/richardnguyen99/gatsby-mdx-blog-template

Steps to Reproduce

  1. Vercel app: https://gatsby-mdx-blog-template.vercel.app/
  2. Netlify app: https://gatsby-mdx-blog-starter.netlify.app/

Expected Result

Expect the SSR APIs to work on major hosting services for GatsbyJS

Actual Result

Get crashes with two different errors using the same app source.

Environment

System:
    OS: Linux 6.12 Fedora Linux 41 (Workstation Edition)
    CPU: (12) x64 Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
    Shell: 3.7.0 - /usr/bin/fish
  Binaries:
    Node: 22.12.0 - /usr/local/bin/node
    Yarn: 1.22.21 - /usr/local/bin/yarn
    npm: 11.1.0 - /usr/local/bin/npm
  Languages:
    Python: 3.13.1 - /usr/bin/python
  Browsers:
    Chrome: 133.0.6943.53
  npmPackages:
    gatsby: ^5.14.1 => 5.14.1
    gatsby-adapter-netlify: ^1.2.0 => 1.2.0
    gatsby-plugin-google-gtag: ^5.14.0 => 5.14.0
    gatsby-plugin-image: ^3.14.0 => 3.14.0
    gatsby-plugin-manifest: ^5.14.0 => 5.14.0
    gatsby-plugin-mdx: ^5.14.0 => 5.14.0
    gatsby-plugin-netlify: ^5.1.1 => 5.1.1
    gatsby-plugin-postcss: ^6.14.0 => 6.14.0
    gatsby-plugin-sharp: ^5.14.0 => 5.14.0
    gatsby-plugin-sitemap: ^6.14.0 => 6.14.0
    gatsby-remark-images: ^7.14.0 => 7.14.0
    gatsby-source-filesystem: ^5.14.0 => 5.14.0
    gatsby-transformer-remark: ^6.14.0 => 6.14.0
    gatsby-transformer-sharp: ^5.14.0 => 5.14.0
  npmGlobalPackages:
    gatsby-cli: 5.11.0

Config Flags

DEV_SSR: true

@richardnguyen99 richardnguyen99 added the type: bug An issue or pull request relating to a bug in Gatsby label Feb 8, 2025
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Feb 8, 2025
@McLeodSean
Copy link

@richardnguyen99 - FYI, on Netlify this issue is caused by an incompatibility between libvips in the new Ubuntu Noble 24.04 build image and older versions of sharp as noted here.

Switching the Netlify build image to Ubuntu Focal 20.04 fixes this issue for us, but the long term solution should be upgrading any sharp dependencies in Gatsby to newer versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

2 participants