Skip to content

Commit c0c8ce8

Browse files
authored
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 9f2fb93 commit c0c8ce8

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
@@ -1282,6 +1282,13 @@ register('./my-hooks.mjs', {
12821282
});
12831283
```
12841284
1285+
A hook can send messages to the thread that registered it at any time, as
1286+
above. It must not block on a reply from that thread: resolution and loading
1287+
are synchronous from the perspective of the thread that triggered them, so that
1288+
thread is blocked until the hook settles and cannot answer in the meantime.
1289+
Hooks can otherwise be fully asynchronous; it is only a reply over this
1290+
message channel that cannot be awaited.
1291+
12851292
#### Asynchronous hooks accepted by `module.register()`
12861293
12871294
<!-- YAML

0 commit comments

Comments
 (0)