Skip to content

Commit f534a4c

Browse files
bitpshraduh95
authored andcommitted
doc: warn against awaiting replies in module hooks
Awaiting a reply from the registering thread inside a resolve or load hook deadlocks: resolution is synchronous from that thread's perspective, so it is blocked in the request and cannot answer. Fixes: #63085 Signed-off-by: Paul Bouchon <mail@bitpshr.net> PR-URL: #65590 Reviewed-By: Jacob Smith <jacob@frende.me>
1 parent bfeb390 commit f534a4c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎doc/api/module.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,13 @@ register('./my-hooks.mjs', {
12721272
});
12731273
```
12741274
1275+
A hook can send messages to the thread that registered it at any time, as
1276+
above. It must not block on a reply from that thread: resolution and loading
1277+
are synchronous from the perspective of the thread that triggered them, so that
1278+
thread is blocked until the hook settles and cannot answer in the meantime.
1279+
Hooks can otherwise be fully asynchronous; it is only a reply over this
1280+
message channel that cannot be awaited.
1281+
12751282
#### Asynchronous hooks accepted by `module.register()`
12761283
12771284
<!-- YAML

0 commit comments

Comments
 (0)