diff options
author | Robert Nagy <ronagy@icloud.com> | 2020-04-30 21:29:35 +0300 |
---|---|---|
committer | Robert Nagy <ronagy@icloud.com> | 2020-05-10 23:11:21 +0300 |
commit | 8a6fab02adab2de05f6e864847f96b0924be0840 (patch) | |
tree | 3bb8d04d5e5e607c26d92b6c15bfe3700860a5d7 /doc/api/http.md | |
parent | cbf2fa63d7ffb6f7e129086c2d85b306ef247186 (diff) |
http: emit 'error' on aborted server request
Server requests aka. IncomingMessage emits 'aborted'
instead of 'error' which causes confusion when
the object is used as a regular stream, i.e. if
functions working on streams are passed a
server request object they might not work properly
unless they take this into account.
Refs: https://github.com/nodejs/web-server-frameworks/issues/41
PR-URL: https://github.com/nodejs/node/pull/33172
Fixes: https://github.com/nodejs/node/issues/28172
Refs: https://github.com/nodejs/node/pull/28677
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'doc/api/http.md')
-rw-r--r-- | doc/api/http.md | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/doc/api/http.md b/doc/api/http.md index a6f73ee94f9..e924a2dc312 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -333,9 +333,8 @@ Until the data is consumed, the `'end'` event will not fire. Also, until the data is read it will consume memory that can eventually lead to a 'process out of memory' error. -Unlike the `request` object, if the response closes prematurely, the -`response` object does not emit an `'error'` event but instead emits the -`'aborted'` event. +For backward compatibility, `res` will only emit `'error'` if there is an +`'error'` listener registered. Node.js does not check whether Content-Length and the length of the body which has been transmitted are equal or not. @@ -2417,6 +2416,8 @@ the following events will be emitted in the following order: * `'data'` any number of times, on the `res` object * (connection closed here) * `'aborted'` on the `res` object +* `'error'` on the `res` object with an error with message + `'Error: aborted'` and code `'ECONNRESET'`. * `'close'` * `'close'` on the `res` object @@ -2445,6 +2446,8 @@ events will be emitted in the following order: * `'data'` any number of times, on the `res` object * (`req.destroy()` called here) * `'aborted'` on the `res` object +* `'error'` on the `res` object with an error with message + `'Error: aborted'` and code `'ECONNRESET'`. * `'close'` * `'close'` on the `res` object @@ -2474,6 +2477,8 @@ events will be emitted in the following order: * (`req.abort()` called here) * `'abort'` * `'aborted'` on the `res` object +* `'error'` on the `res` object with an error with message + `'Error: aborted'` and code `'ECONNRESET'`. * `'close'` * `'close'` on the `res` object |