Skip to content

fix(cloudflare): detect implicit nodejs_compat when deployConfig is false - #4667

Merged
pi0 merged 4 commits into
nitrojs:v2from
agustin18:fix/cloudflare-implicit-node-compat-4649
Sep 25, 2026
Merged

pi0 merged 4 commits into
nitrojs:v2from
agustin18:fix/cloudflare-implicit-node-compat-4649

Conversation

@agustin18

Copy link
Copy Markdown

🔗 Linked issue

Closes #4649

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)

📚 Description

Cloudflare enables Node.js compatibility by default for compatibility dates on or after 2026-08-04.

When cloudflare.deployConfig is set to false and the user's Wrangler config does not contain an explicit nodejs_compat flag (following Cloudflare's guidance where the explicit flag is redundant for modern dates), enableNodeCompat() failed to infer that Node.js compatibility was active. As a result, Nitro omitted the hybrid node compat plugin and unenv node compat configuration, falling back to stubbed implementations that throw at runtime (e.g. [unenv] crypto.createHash is not implemented yet!).

This fix:

  1. Infers Node.js compatibility as implicitly enabled (isDefaultNodeCompat) when the resolved compatibility date is on or after NODEJS_COMPAT_DEFAULT_ON_DATE (2026-08-04), provided no negative flags (no_nodejs_compat, no_nodejs_compat_v2) are specified.
  2. Checks both Wrangler config and nitro.options.compatibilityDate.
  3. Adds comprehensive unit tests in test/unit/cloudflare.utils.test.ts covering implicit detection, explicit negative flags, wrangler.toml parsing, and deployConfig states.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

…alse

Closes nitrojs#4649

Infer Node.js compatibility when compatibility_date is on or after
NODEJS_COMPAT_DEFAULT_ON_DATE (2026-08-04) and no negative compatibility flag
(no_nodejs_compat or no_nodejs_compat_v2) is present, even when deployConfig
is false and no explicit nodejs_compat flag is set.
@vercel

vercel Bot commented Sep 25, 2026

Copy link
Copy Markdown

@agustin18 is attempting to deploy a commit to the Nitro Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 75f9af1b-440e-46e4-b631-71ad6cb1e11e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pi0 pi0 added the v2 label Sep 25, 2026
pi0 and others added 3 commits September 25, 2026 16:28
…implicit-node-compat-4649

# Conflicts:
#	src/presets/cloudflare/utils.ts
`no_nodejs_compat_v2` only disables the v2 extras; `nodejs_compat` (v1) is
still on by default from 2026-08-04. Nitro v2 adds this flag itself, so it
must not disable nodeCompat inference.
@pi0
pi0 merged commit 91c3e5f into nitrojs:v2 Sep 25, 2026
8 of 9 checks passed
@pi0x pi0x removed the v2 label Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants