Skip to content

Use the native node:tty, node:repl, node:readline, node:inspector, node:v8, and node:dgram modules when available#11026

Closed
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1760951676-node-tty
Closed

Use the native node:tty, node:repl, node:readline, node:inspector, node:v8, and node:dgram modules when available#11026
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1760951676-node-tty

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:tty, node:repl, node:readline, node:inspector, node:v8, and node:dgram modules 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. This PR combines 6 modules that follow the same conversion pattern.

Changes

  • Added override functions for each module: getTtyOverrides(), getReplOverrides(), getReadlineOverrides(), getInspectorOverrides(), getV8Overrides(), getDgramOverrides()
  • Integrated all overrides into the preset system (both nativeModules and hybridModules)
  • Added E2E tests for enable/disable flag behavior for each module
  • Each module requires experimental flag and its respective enable_nodejs_*_module flag
  • Each can be disabled with its respective disable_nodejs_*_module flag

Key Differences: workerd vs unenv

node:tty - Workerd extends Socket with complete WriteStream methods (getColorDepth, hasColors, getWindowSize) and throws proper errors. Unenv has simpler stubs.

node:repl - Workerd has proper class structures with all properties defined. Unenv uses notImplemented helpers. Both non-functional.

node:readline (+ promises) - Very similar implementations. Both are mostly no-ops. Workerd is more consistent.

node:inspector (+ promises) - Workerd has proper Session class extending EventEmitter. Unenv uses helper functions.

node:v8 - Workerd throws ERR_METHOD_NOT_IMPLEMENTED explicitly and validates inputs. Unenv returns mock data silently. Workerd has additional methods (getCppHeapStatistics, isStringOneByteRepresentation).

node:dgram - Workerd has complete Socket API with all methods (bind, connect, send, close) and Symbol.asyncDispose support. Unenv has basic implementation.

Review Focus

  • Verify flag naming follows convention for each 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 (pbacondarwin@cloudflare.com)


  • 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

…de:v8, and node:dgram modules when available

Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
@devin-ai-integration devin-ai-integration bot requested a review from a team October 20, 2025 09:18
@devin-ai-integration devin-ai-integration bot requested a review from a team as a code owner October 20, 2025 09:18
@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2025

🦋 Changeset detected

Latest commit: 6265ecb

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

@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

@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/1760951676-node-tty might be a good starting point.

Notes:

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

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.

I think there should be 1 PR per module so that they are easier to review and potentially revert.
Each PR description should clearly mention the breaking changes

@petebacondarwin petebacondarwin added the nodejs compat Relating to the node runtime compatibility flag label Dec 15, 2025
@github-project-automation github-project-automation bot moved this from Untriaged to Done in workers-sdk Dec 23, 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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants