Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
doc: add message.signal to http IncomingMessage documentation
  • Loading branch information
akshatsrivastava11 committed Apr 3, 2026
commit 48d116f561b3f95518ad8d01ba7c285e441b6c76
45 changes: 45 additions & 0 deletions doc/api/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -2989,6 +2989,51 @@ added: v0.5.9

Calls `message.socket.setTimeout(msecs, callback)`.

### `message.signal`

<!-- YAML
added: REPLACEME
-->

* Type: {AbortSignal}

An {AbortSignal} that is aborted when the underlying socket closes or the
request is destroyed. The signal is created lazily on first access — no
{AbortController} is allocated for requests that never use this property.

This is useful for cancelling downstream asynchronous work such as database
queries or `fetch` calls when a client disconnects mid-request.

```mjs
import http from 'node:http';

http.createServer(async (req, res) => {
try {
const data = await fetch('https://example.com/api', { signal: req.signal });
res.end(JSON.stringify(await data.json()));
} catch (err) {
if (err.name === 'AbortError') return;
res.statusCode = 500;
res.end('Internal Server Error');
}
}).listen(3000);
```

```cjs
const http = require('node:http');

http.createServer(async (req, res) => {
try {
const data = await fetch('https://example.com/api', { signal: req.signal });
res.end(JSON.stringify(await data.json()));
} catch (err) {
if (err.name === 'AbortError') return;
res.statusCode = 500;
res.end('Internal Server Error');
}
}).listen(3000);
```

### `message.socket`

<!-- YAML
Expand Down
Loading