Use the native node:domain module when available#11353
Conversation
🦋 Changeset detectedLatest commit: 4770579 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
@cloudflare/workers-utils
wrangler
commit: |
petebacondarwin
left a comment
There was a problem hiding this comment.
- Unenv code: https://github.com/unjs/unenv/blob/main/src/runtime/node/internal/domain/domain.ts
- workerd code: https://github.com/cloudflare/workerd/blob/main/src/node/domain.ts
- Node.js code: https://github.com/nodejs/node/blob/main/lib/domain.js
I checked how the workerd implementation compares to unenv... Most methods are equivalent noops. The bind, intercept and run methods used to throw in unenv but now just return the callback with no side-effects.
The one potential breaking change is that the members property in unenv is initialized to [] but is undefined in workerd. But this is what Node.js does itself so we are good there.
The native implementation is available since cloudflare/workerd#5031
It is a superset of the unenv implementation.
/cc @anonrig @jasnell