Skip to content

fix: guard setupFsWrapper loop against missing fs keys on Node 24#39573

Open
McLeodSean wants to merge 2 commits into
gatsbyjs:masterfrom
McLeodSean:fix/setup-fs-wrapper-node-24
Open

fix: guard setupFsWrapper loop against missing fs keys on Node 24#39573
McLeodSean wants to merge 2 commits into
gatsbyjs:masterfrom
McLeodSean:fix/setup-fs-wrapper-node-24

Conversation

@McLeodSean

Copy link
Copy Markdown

Description

Guards the setupFsWrapper loop in packages/gatsby/src/utils/page-ssr-module/lambda.ts
against fs[key] being undefined.

On Node 24, fs.F_OK, fs.R_OK, fs.W_OK, and fs.X_OK are non-enumerable getters
(DEP0176). They drop out of fs-extra's spread re-exports, so fs-extra.F_OK === undefined
on Node 24. linkfs then writes those names onto the linked object as undefined. The
existing loop calls Object.hasOwnProperty.call(fs[key], 'native') without a null check
and crashes on Node 24 in any read-only filesystem deploy (Netlify Functions, etc.).

Documentation

N/A

Tests

No tests exist for lambda.ts (seems gnarly), but this change is a safer option than the existing solution.

Related Issues

@gatsbot gatsbot Bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label May 13, 2026

@serhalp serhalp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@serhalp serhalp added status: accepted and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels May 25, 2026
@serhalp serhalp self-assigned this May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setupFsWrapper crashes on Node 24 with "Cannot convert undefined or null to object"

2 participants