Skip to content

Commit 8bf7793

Browse files
committed
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 70d8850 commit 8bf7793

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
@@ -140,13 +140,10 @@ to as `node::Environment`. Each `node::Environment` is associated with:
140140

141141
`node::Environment`s that share a `node::IsolateData` also share its
142142
`uv_loop_t`. `node::FreeEnvironment()` runs that loop until the handles of the
143-
`node::Environment` being freed have closed, and JavaScript execution is
144-
disallowed on the whole `v8::Isolate` while it does, so pending timers, I/O
145-
callbacks and thread pool completions that belong to other `node::Environment`s
146-
on the same loop can run inside that call without being able to call into
147-
JavaScript. `node::Environment`s that are freed independently of one another
148-
should each use their own `uv_loop_t` and `node::IsolateData`, or the embedder
149-
should make sure the others have no pending work when one of them is freed.
143+
`node::Environment` being freed have closed. Timers, I/O callbacks and thread
144+
pool completions of the other `node::Environment`s that become due in those
145+
loop iterations run normally, including their JavaScript; only the
146+
`node::Environment` being freed can no longer call into JavaScript.
150147

151148
In order to set up a `v8::Isolate`, an `v8::ArrayBuffer::Allocator` needs
152149
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
@@ -925,8 +925,8 @@ NODE_EXTERN v8::MaybeLocal<v8::Value> LoadEnvironment(
925925
EmbedderPreloadCallback preload = nullptr);
926926

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

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

0 commit comments

Comments
 (0)