Skip to content

Conversation

@devin-ai-integration
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot commented Oct 20, 2025

Adds support for using the native node:wasi module from workerd when available, following the pattern established in previous module conversion PRs.

This is part of a series to convert 9 remaining Node.js modules from unenv polyfills to native workerd implementations.

Changes

  • Added getWasiOverrides() function to enable/disable the native wasi module based on compatibility flags
  • Integrated wasi overrides into the preset system (both nativeModules and hybridModules)
  • Added E2E tests for enable/disable flag behavior
  • Requires experimental flag and enable_nodejs_wasi_module flag to enable
  • Can be disabled with disable_nodejs_wasi_module flag

Key Differences: workerd vs unenv

The workerd implementation has complete constructor validation for all WASI options (version, args, env, preopens, stdin, stdout, stderr, returnOnExit), while unenv just throws immediately without validation. Both are non-functional stubs.

Review Focus

  • Verify flag naming follows convention: enable_nodejs_wasi_module / disable_nodejs_wasi_module
  • Confirm implementation matches the pattern from cluster/punycode modules
  • Check test coverage is consistent with existing module tests

Link to Devin run: https://app.devin.ai/sessions/f2a8f635e47b47e8baa9bc1b68af0635
Requested by: @petebacondarwin ([email protected])


  • Tests
    • Tests included
  • Public documentation
    • Documentation not necessary because: this is an experimental feature requiring the experimental flag
  • Wrangler V3 Backport
    • Not necessary because: unenv-preset changes are never backported to v3

@devin-ai-integration devin-ai-integration bot requested a review from a team October 20, 2025 09:13
@devin-ai-integration devin-ai-integration bot requested a review from a team as a code owner October 20, 2025 09:13
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2025

🦋 Changeset detected

Latest commit: 8829564

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

Failed to automatically backport this PR's changes to Wrangler v3. Please manually create a PR targeting the v3-maintenance branch with your changes. Thank you for helping us keep Wrangler v3 supported!

Depending on your changes, running git rebase --onto v3-maintenance main devin/1760951437-node-wasi might be a good starting point.

Notes:

  • your PR branch should be named v3-backport-11025
  • add the skip-v3-pr label to the current PR to stop this workflow from failing

@devin-ai-integration devin-ai-integration bot added the skip-v3-pr Skip validation of presence of a v3 backport PR label Oct 20, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 20, 2025

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@11025

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@11025

miniflare

npm i https://pkg.pr.new/miniflare@11025

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@11025

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@11025

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@11025

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@11025

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@11025

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@11025

wrangler

npm i https://pkg.pr.new/wrangler@11025

commit: 8829564

@petebacondarwin petebacondarwin force-pushed the devin/1760951437-node-wasi branch from c39b635 to 295ddc7 Compare November 18, 2025 10:27
@petebacondarwin
Copy link
Contributor

Here is the unenv polyfill: https://github.com/unjs/unenv/blob/6493c25f2fb94b9f2c7dec528a26ac11f7f9b8b0/src/runtime/node/wasi.ts#L2

@petebacondarwin
Copy link
Contributor

Here is the workerd implementation: https://github.com/cloudflare/workerd/blob/6daa2ba8e02a3ea25cc7afd60d70f70bd9a38c7e/src/node/wasi.ts#L22

@petebacondarwin
Copy link
Contributor

Here is the Node.js implementation https://github.com/nodejs/node/blob/0b6ae6df14ac7b6dbec4ad5c0473b63072d98cff/lib/wasi.js#L37

@petebacondarwin petebacondarwin force-pushed the devin/1760951437-node-wasi branch from 3a78787 to 7316bdf Compare November 18, 2025 13:22
Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

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

Thanks Pete!

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Nov 18, 2025
@devin-ai-integration
Copy link
Contributor Author

❌ Cannot revive Devin session - the session is too old. Please start a new session instead.

@vicb vicb force-pushed the devin/1760951437-node-wasi branch from dcebd73 to 55423bc Compare November 20, 2025 08:27
@vicb
Copy link
Contributor

vicb commented Nov 20, 2025

force push is rebase + format

@vicb vicb force-pushed the devin/1760951437-node-wasi branch from 55423bc to 8829564 Compare November 20, 2025 10:46
@vicb
Copy link
Contributor

vicb commented Nov 20, 2025

rebased (with conflicts resolution)

@dario-piotrowicz dario-piotrowicz merged commit 4a158e9 into main Nov 20, 2025
34 of 35 checks passed
@dario-piotrowicz dario-piotrowicz deleted the devin/1760951437-node-wasi branch November 20, 2025 12:04
@github-project-automation github-project-automation bot moved this from Approved to Done in workers-sdk Nov 20, 2025
@petebacondarwin petebacondarwin added the nodejs compat Relating to the node runtime compatibility flag label Dec 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

nodejs compat Relating to the node runtime compatibility flag skip-v3-pr Skip validation of presence of a v3 backport PR

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

3 participants