-
Notifications
You must be signed in to change notification settings - Fork 1k
Use the native node:domain module when available
#11023
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
🦋 Changeset detectedLatest commit: 2c83c3d 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 |
|
Failed to automatically backport this PR's changes to Wrangler v3. Please manually create a PR targeting the Depending on your changes, running Notes:
|
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
|
Note that the unenv: export const active = () => _domain;workerd: // The active domain is always the one that we're currently in.
export const active: Domain | null = null;nodejs: // The active domain is always the one that we're currently in.
exports.active = null; |
|
Note that workerd does not export the internal undocumented |
|
Thanks for documenting these differences! You're right that:
Both of these differences make workerd's implementation more correct/compatible with Node.js, which is the goal of this conversion. |
|
Finally note that the Domain member property But in the Node.js codebase it has a weird setup where the constructor sets the instance to Domain.prototype.members = undefined;And elsewhere it is possible for member to be set to either |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - @vicb should also take a view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM.
|
Actually, the PR is missing basic tests for the domain module |
5bcc9b0 to
358c463
Compare
😱 - you're absolutely right, I totally missed this. |
Co-Authored-By: [email protected] <[email protected]>
Adds support for using the native
node:domainmodule from workerd when available, following the pattern established in previous module conversion PRs.This is the first PR in a series to convert 9 remaining Node.js modules from unenv polyfills to native workerd implementations.
Changes
getDomainOverrides()function to enable/disable the native domain module based on compatibility flagsexperimentalflag andenable_nodejs_domain_moduleflag to enabledisable_nodejs_domain_moduleflagKey Differences: workerd vs unenv
The workerd implementation has a more complete Domain API surface with all methods (enter, exit, add, remove, run, intercept, bind) compared to unenv's basic implementation. Both implementations are non-functional stubs, but workerd throws explicit
ERR_METHOD_NOT_IMPLEMENTEDerrors and has better validation.Review Focus
enable_nodejs_domain_module/disable_nodejs_domain_moduleLink to Devin run: https://app.devin.ai/sessions/f2a8f635e47b47e8baa9bc1b68af0635
Requested by: @petebacondarwin ([email protected])