From 2620769e7fd9961c170031fe1296cb780bff5c2a Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 19 Jul 2017 07:26:15 -0700 Subject: [PATCH] http2: refinement and test for socketError Fixes: https://github.com/nodejs/http2/issues/184 Refines the `'socketError'` event a bit and adds a test for the emission of the `'socketError'` event on the server. Client side is tested separately Backport-PR-URL: https://github.com/nodejs/node/pull/14813 Backport-Reviewed-By: Anna Henningsen Backport-Reviewed-By: Timothy Gu PR-URL: https://github.com/nodejs/node/pull/14239 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Matteo Collina --- doc/api/http2.md | 16 +++--- lib/internal/http2/core.js | 31 ++++------- .../parallel/test-http2-server-socketerror.js | 52 +++++++++++++++++++ 3 files changed, 70 insertions(+), 29 deletions(-) create mode 100755 test/parallel/test-http2-server-socketerror.js diff --git a/doc/api/http2.md b/doc/api/http2.md index 9beb2cac922986..6bc1543c079f8a 100755 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -254,9 +254,9 @@ The `'socketError'` event is emitted when an `'error'` is emitted on the `Socket` instance bound to the `Http2Session`. If this event is not handled, the `'error'` event will be re-emitted on the `Socket`. -Likewise, when an `'error'` event is emitted on the `Http2Session`, a -`'sessionError'` event will be emitted on the `Socket`. If that event is -not handled, the `'error'` event will be re-emitted on the `Http2Session`. +For `ServerHttp2Session` instances, a `'socketError'` event listener is always +registered that will, by default, forward the event on to the owning +`Http2Server` instance if no additional handlers are registered. #### Event: 'timeout' -The `'socketError'` event is emitted when an `'error'` event is emitted by -a `Socket` associated with the server. If no listener is registered for this -event, an `'error'` event is emitted. +The `'socketError'` event is emitted when a `'socketError'` event is emitted by +an `Http2Session` associated with the server. #### Event: 'stream' -The `'socketError'` event is emitted when an `'error'` event is emitted by -a `Socket` associated with the server. If no listener is registered for this -event, an `'error'` event is emitted on the `Socket` instance instead. +The `'socketError'` event is emitted when a `'socketError'` event is emitted by +an `Http2Session` associated with the server. #### Event: 'unknownProtocol'