Skip to content

Conversation

@petebacondarwin
Copy link
Contributor

@petebacondarwin petebacondarwin commented Jan 20, 2026

Devin PR requested by @petebacondarwin

Adds support for the native node:repl module from workerd when the enable_nodejs_repl_module and experimental compatibility flags are enabled. This follows the same pattern as other experimental modules (inspector, sqlite, dgram, stream_wrap).

The native code appears in workerd as of https://github.com/cloudflare/workerd/blob/main/src/node/repl.ts. It is currently experimental with no default enable date.

Implementation Comparison

Export workerd unenv node.js Breaking change?
writer throws ERR_METHOD_NOT_IMPLEMENTED throws "not implemented" full implementation No (both throw)
start throws ERR_METHOD_NOT_IMPLEMENTED throws "not implemented" full implementation No (both throw)
Recoverable class extending SyntaxError notImplementedClass full implementation No (both throw on use)
REPLServer class, constructor throws notImplementedClass full implementation No (both throw on use)
REPL_MODE_SLOPPY unique symbol unique symbol unique symbol No (same)
REPL_MODE_STRICT unique symbol unique symbol unique symbol No (same)
builtinModules array of module names array from node:module array of module names No (same)
_builtinLibs alias for builtinModules alias for builtinModules alias for builtinModules No (same)

Breaking change analysis: There are no breaking changes when moving from unenv to workerd. Both implementations throw errors for the main functions (writer, start, REPLServer, Recoverable). The only difference is the error type/message - workerd throws ERR_METHOD_NOT_IMPLEMENTED (Node.js style) while unenv throws a generic "not implemented" error. The workerd implementation is moving closer to Node.js by using proper Node.js error codes.

Updates since last revision

  • Refactored test code to use assertTypeOfProperties for symbol assertions (REPL_MODE_SLOPPY, REPL_MODE_STRICT) per review feedback

Human Review Checklist

  • Verify the getReplOverrides() function follows the same pattern as other experimental modules
  • Confirm the test regex /not implemented|ERR_METHOD_NOT_IMPLEMENTED/ correctly handles both error types

Link to Devin run


  • Tests
    • Tests included
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: internal experimental feature, follows existing patterns
  • Wrangler V3 Backport
    • Wrangler PR:
    • Not necessary because: unenv-preset is not backported

Open with Devin

@devin-ai-integration
Copy link
Contributor

🤖 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 that start with 'DevinAI' or '@devin'.
  • 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 Jan 20, 2026

🦋 Changeset detected

Latest commit: 9ef23b8

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

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 20, 2026

create-cloudflare

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

@cloudflare/kv-asset-handler

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

miniflare

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

@cloudflare/pages-shared

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

@cloudflare/unenv-preset

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

@cloudflare/vite-plugin

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

@cloudflare/vitest-pool-workers

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

@cloudflare/workers-editor-shared

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

@cloudflare/workers-utils

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

wrangler

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

commit: 9ef23b8

@petebacondarwin petebacondarwin added the skip-changeset-review Skips Claude's changeset review label Jan 21, 2026
devin-ai-integration bot and others added 2 commits January 21, 2026 13:59
Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
@petebacondarwin petebacondarwin force-pushed the devin/1768931616-native-node-repl branch from 14425eb to 8cad740 Compare January 21, 2026 13:59
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.

LGTM, one nit

const repl = await import("node:repl");

// Common exports (both unenv stub and native workerd)
assertTypeOfProperties(repl, {
Copy link
Contributor

@vicb vicb Jan 21, 2026

Choose a reason for hiding this comment

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

nit: we could factor code

for (const target of [repl, repl.default]) {
  assertTypeOfProperties(target, { ... });
}

we could also do that across the file

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can do that in a general refactor PR afterwards?

@github-project-automation github-project-automation bot moved this from Untriaged to Approved in workers-sdk Jan 21, 2026
@vicb vicb marked this pull request as ready for review January 21, 2026 16:05
@vicb vicb requested a review from a team as a code owner January 21, 2026 16:05
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional flags.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changeset-review Skips Claude's changeset review

Projects

Status: Approved

Development

Successfully merging this pull request may close these issues.

2 participants