Commit e48657ac13f for nodejs
commit e48657ac13f7cb687eeaa8adf5b2bb057fee8d0d
Author: lightning4747 <Vignesh112847@gmail.com>
Date: Sun Dec 6 02:00:11 2026 +0530
doc: clarify sendingHeaders listener timing
Assisted-by: Codex
Signed-off-by: lightning4747 <vignesh112847@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/67969
Fixes: https://github.com/nodejs/node/issues/67963
Refs: https://github.com/nodejs/node/pull/63996
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
diff --git a/doc/api/http.md b/doc/api/http.md
index 25485f1fd80..984babeaaab 100644
--- a/doc/api/http.md
+++ b/doc/api/http.md
@@ -2142,9 +2142,10 @@ Because it is a single emission point, multiple independent listeners (for
example logging, session, and content-negotiation middleware) can each register
without coordinating with one another. Listeners run in registration order.
-The listener runs synchronously and must not be an `async` function: work
-deferred past an `await` runs after the headers are already sent, so only
-changes made synchronously take effect.
+Node.js calls listeners synchronously and does not wait for promises they
+return. Header and status changes must happen during the synchronous part of
+the listener: work deferred past an `await` runs after the headers are already
+sent, so only synchronous changes take effect.
```js
const server = http.createServer((req, res) => {
diff --git a/doc/api/http2.md b/doc/api/http2.md
index 5d45b0fef70..af8b897cbc0 100644
--- a/doc/api/http2.md
+++ b/doc/api/http2.md
@@ -4681,8 +4681,10 @@ The event is reached by every header-flushing path
([`response.writeHead()`][], implicit headers from the first
[`response.write()`][] or [`response.end()`][], and `response.flushHeaders()`),
so independent middleware can each register a listener without coordinating.
-Listeners run in registration order and must be synchronous; changes deferred
-past an `await` run after the headers are already sent and have no effect.
+Listeners run in registration order. Node.js calls them synchronously and does
+not wait for promises they return. Header and status changes must happen during
+the synchronous part of the listener: work deferred past an `await` runs after
+the headers are already sent, so only synchronous changes take effect.
This is the HTTP/2 counterpart of the HTTP/1
[`'sendingHeaders'`](http.md#event-sendingheaders) event.