-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Closed
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.
Description
Affected URL(s)
https://nodejs.org/api/http.html#class-httpincomingmessage
Description of the problem
The "aborted" event is deprecated and states "Deprecated. Listen for 'close' event instead." which isn't related in any way.
The close event fires whenever the stream is CLOSED while the aborted event only fires if the request is ABORTED.
For exmaple a little HTTP-Server:
// server.js
const http = require('http')
const server = http.createServer((request, response) => {
request.on('error', (error) => {
console.error('> THERE WAS AN ERROR', error)
})
request.on('aborted', () => {
console.log('> REQUEST GOT ABORTED')
})
request.on('close', () => {
console.log('> REQUEST GOT CLOSED')
response.end('CLOSED');
})
request.resume(); // CONSUME ALL DATA
});
server.on('listening', () => console.log('HTTP-Server is running.'));
server.listen(3100, '127.0.0.1');And some simple curl requests to this http server:
curl -F file=somesmallfile.bin http://127.0.0.1:3100
REQUEST GOT CLOSEDcurl -F file=somebigfile.bin --limit-rate 1K http://127.0.0.1:3100 and cancel CTRL+C
REQUEST GOT ABORTED
THERE WAS AN ERROR Error: aborted
at connResetException (node:internal/errors:704:14)
at abortIncoming (node:_http_server:680:17)
at socketOnClose (node:_http_server:674:3)
at Socket.emit (node:events:549:35)
at TCP.<anonymous> (node:net:747:14) {
code: 'ECONNRESET'
}
REQUEST GOT CLOSEDAs we can see the close event gets triggered in both cases while the abort event only gets triggered in the event of a user interruption. Please clearify this as close isn't an alternative for aborted as stated above.
zbjornson and chefnote-com-admin
Metadata
Metadata
Assignees
Labels
docIssues and PRs related to the documentations.Issues and PRs related to the documentations.