Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -2127,9 +2127,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) => {
Expand Down
6 changes: 4 additions & 2 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down