workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

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

Open devin-ai-integration[bot] opened this issue 2 months ago • 3 comments

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 ([email protected])


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

🦋 Changeset detected

Latest commit: 6265ecb3f5bcbf1acfd54724ee1d24ffc5e7867e

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

changeset-bot[bot] avatar Oct 20 '25 09:10 changeset-bot[bot]

🤖 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

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

github-actions[bot] avatar Oct 20 '25 09:10 github-actions[bot]