-
Notifications
You must be signed in to change notification settings - Fork 134
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
New Strategic Initiative on ShadowRealm #1221
Comments
This sounds like a good idea to me +1. I assume you would volunteer to be the champion? |
Yes, I'd be happy to champion the initiative. |
I think it’d be very challenging to implement because node would need a full membrane implementation, not just ShadowRealm (since many core node module functions require object identities to be input and preserved in the output), but it’s definitely worth exploring. |
I believe this issue can now be closed as its been added as a strategic initiative and there is another issue which ongoing discussion can take place. |
ShadowRealm is a stage 3 TC39 proposal. ShadowRealm provides a strong guarantee on isolating object graphs between different JavaScript executing contexts and introduces a new built-in to provide a distinct global environment. ShadowRealm also ensures the module graph it uses is isolated from its outer contexts.
It may sound similar to the Node.js
vm
module at the first look, but it actually opens up a different possibility for running code modules in one Isolate without interfering with each other. I've posted an issue to discuss the details about this: nodejs/node#42528.The web is adopting ShadowRealm. They are working on exposing a curated useful web built-in APIs to the ShadowRealm, like EventTarget, Stream, etc. This is what Node.js
vm
module is missing all the time: people pass the outer builtin API objects into the VM and get confused by the obscureobj instanceof Object
result, or have to find the alternatives in the wild and require them in thevm
. Apart from the built-in APIs, there are also global events likeuncaughtException
andunhandledRejection
, andasync_hooks
that need to be designed to fit in the model correctly.To support exposing Node.js own built-in API in the ShadowRealm (or maybe in the
vm
too!), we need to disentangle the native modules from the main context and make it possible to evaluate those native modules in the ShadowRealm's context again. This could be a lot of work since people are not aware of if a native module written in Node.js can be evaluated multiple times in one single Environment. It will be a good effort to refactor the codebase to disentangle this. Also, we may need to be able to snapshot the startup state too to boost the performance of creating the new contexts for ShadowRealm.This work is likely to be a long-term effort and lots of decisions to make. I believe establishing a strategic initiative will help share progress and increase TSC awareness/attention on the topic. I'd be happy to champion the initiative.
The text was updated successfully, but these errors were encountered: