setupFsWrapper crashes on Node 24 with "Cannot convert undefined or null to object"
Preliminary Checks
- This issue is not a duplicate. Before opening a new issue, please search existing issues: https://github.com/gatsbyjs/gatsby/issues
- This issue is not a question, feature request, RFC, or anything other than a bug report directly related to Gatsby. Please post those things in GitHub Discussions: https://github.com/gatsbyjs/gatsby/discussions
Description
When a Gatsby site with SSR or DSG routes is deployed to a read-only lambda environment (Netlify Functions, AWS Lambda, etc.) and run on Node 24, the SSR lambda crashes on first invocation with:
TypeError: Cannot convert undefined or null to object
at hasOwnProperty (<anonymous>)
at setupFsWrapper (/var/task/.cache/page-ssr/lambda.js:101:33)
The crash is in packages/gatsby/src/utils/page-ssr-module/lambda.ts, in the loop that copies native props from fs onto the linkfs-wrapped object.
Reproduction Link
https://gist.github.com/McLeodSean/8b541d86e3022a80b0c1b9064bf6171d
Steps to Reproduce
Added a minimal repro gist, as the issue is tightly scoped to some logic that doesn't run locally.
mkdir gatsby-ssr-node24-repro && cd gatsby-ssr-node24-repro
npm init -y
npm install fs-extra@11 linkfs@2
nvm install 24 && nvm use 24
Save as repro.js:
const fs = require('fs-extra')
const linkfs = require('linkfs')
console.log('node:', process.version)
console.log('fs-extra F_OK:', fs.F_OK) // undefined on Node 24, 0 on Node 22
linkfs.rewritableMethods.push('createWriteStream', 'createReadStream', 'rm')
const lfs = linkfs.link(fs, [['/tmp/a', '/tmp/b']])
// This is the loop from packages/gatsby/src/utils/page-ssr-module/lambda.ts
for (const key in lfs) {
if (Object.hasOwnProperty.call(fs[key], 'native')) {
lfs[key].native = fs[key].native
}
}
Run:
node repro.js
Expected Result
The loop completes without throwing. fs[key].native is copied for keys where it exists, skipped where the source value is missing.
Actual Result
Crashes on Node 24 with:
TypeError: Cannot convert undefined or null to object
at hasOwnProperty (<anonymous>)
Switching to Node 22 (nvm use 22 && node repro.js) passes without error.
Environment
System:
OS: macOS 26.5
CPU: (10) arm64 Apple M1 Max
Shell: 5.9 - /bin/zsh
Binaries:
Node: 24.15.0 - /private/var/folders/mn/cs2hpcxs0rs14sz5z_vjjgrc0000gp/T/xfs-a7ddf2ea/node
Yarn: 4.11.0 - /private/var/folders/mn/cs2hpcxs0rs14sz5z_vjjgrc0000gp/T/xfs-a7ddf2ea/yarn
npm: 11.12.1 - ~/.nvm/versions/node/v24.15.0/bin/npm
Browsers:
Chrome: 148.0.7778.97
Safari: 26.5
Config Flags
DEV_SSR: true
FAST_DEV: true
PRESERVE_FILE_DOWNLOAD_CACHE: true
PARALLEL_SOURCING: true
Source: gatsbyjs/gatsby