Skip to content

vm: add experimental NodeRealm implementation#47855

Closed
mcollina wants to merge 30 commits into
nodejs:mainfrom
mcollina:localworker2
Closed

vm: add experimental NodeRealm implementation#47855
mcollina wants to merge 30 commits into
nodejs:mainfrom
mcollina:localworker2

Conversation

@mcollina
Copy link
Copy Markdown
Member

@mcollina mcollina commented May 4, 2023

A NodeRealm is a complete Node.js environment that runs within the same thread. This feature is added behind a --experimental-noderealm flag.

This work is based on #45018, which adds the synchronous-worker module initially written by @addaleax. and is incorporated here with Anna's permission as stated in #45018 by @jasnell (listed as a co-author of this change). The main difference from the synchronous-worker module is that I removed all the "synchronous" parts: it's now impossible to spin the event loop manually.

The reason for including this inside Node.js instead of keeping it as a separate module is access to internal API that would make stop() possible without crashing the process.

This implementation still suffers from a few bugs that I would aim to solve before removing the experimental flags:

  • leaks memory like ShadowRealm (memory leak in shadow realmsΒ #47353);
  • avoid polling during stop();
  • ESM support using internals (instead of the current hack);
  • complete inspector support (currently, it crashes with --inspect-brk due to an async_hooks issue).

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

Labels

lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. notable-change PRs with changes that should be highlighted in changelogs. semver-minor PRs that contain new features and should be released in the next minor version. vm Issues and PRs related to the vm subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.