Skip to content

Commit 510dfd8

Browse files
codebytereaduh95
authored andcommitted
doc: update FreeEnvironment() notes for sibling Environments
With the FreeEnvironment() fix for sibling Environments and the handle cleanup depth tracked per thread, only the Environment being freed loses JavaScript while FreeEnvironment() runs the shared loop. Callbacks of the other Environments on that loop run their JavaScript as usual. Update embedding.md and the comment in node.h, which still describe JavaScript as disallowed on the whole isolate. Signed-off-by: Shelley Vohr <shelley.vohr@gmail.com> PR-URL: #66239 Refs: #65977 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent aead8a9 commit 510dfd8

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

‎doc/api/embedding.md‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,10 @@ to as `node::Environment`. Each `node::Environment` is associated with:
9595
9696
`node::Environment`s that share a `node::IsolateData` also share its
9797
`uv_loop_t`. `node::FreeEnvironment()` runs that loop until the handles of the
98-
`node::Environment` being freed have closed, and JavaScript execution is
99-
disallowed on the whole `v8::Isolate` while it does, so pending timers, I/O
100-
callbacks and thread pool completions that belong to other `node::Environment`s
101-
on the same loop can run inside that call without being able to call into
102-
JavaScript. `node::Environment`s that are freed independently of one another
103-
should each use their own `uv_loop_t` and `node::IsolateData`, or the embedder
104-
should make sure the others have no pending work when one of them is freed.
98+
`node::Environment` being freed have closed. Timers, I/O callbacks and thread
99+
pool completions of the other `node::Environment`s that become due in those
100+
loop iterations run normally, including their JavaScript; only the
101+
`node::Environment` being freed can no longer call into JavaScript.
105102
106103
In order to set up a `v8::Isolate`, an `v8::ArrayBuffer::Allocator` needs
107104
to be provided. One possible choice is the default Node.js allocator, which

‎src/node.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -891,8 +891,8 @@ NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
891891
EmbedderPreloadCallback preload = nullptr);
892892

893893
// Runs `env`'s event loop until its handles have closed, with JavaScript
894-
// execution disallowed on the isolate; see doc/api/embedding.md if that loop
895-
// is shared with other Environments.
894+
// execution disallowed for `env`; see doc/api/embedding.md if that loop is
895+
// shared with other Environments.
896896
NODE_EXTERN void FreeEnvironment(Environment* env);
897897

898898
// Set a callback that is called when process.exit() is called from JS,

0 commit comments

Comments
 (0)