From 7e45f051dea7f352f0eb86398cc4fd5bc87df450 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 26 Aug 2017 12:28:07 -0700 Subject: [PATCH] Revert "http2: refactor error handling" This reverts commit 4ca8ff264f368c301827e07956f313cebd1b8de8. That commit was landed without a green CI and is failing on Windows. PR-URL: https://github.com/nodejs/node/pull/15047 Reviewed-By: James M Snell --- doc/api/http2.md | 39 +------- lib/http2.js | 4 +- lib/internal/http2/compat.js | 16 +-- lib/internal/http2/core.js | 43 ++------ ...p2-client-stream-destroy-before-connect.js | 17 +++- test/parallel/test-http2-compat-errors.js | 52 ---------- test/parallel/test-http2-respond-file-404.js | 47 --------- .../test-http2-respond-file-error-dir.js | 46 --------- test/parallel/test-http2-server-errors.js | 97 ------------------- 9 files changed, 33 insertions(+), 328 deletions(-) delete mode 100644 test/parallel/test-http2-compat-errors.js delete mode 100644 test/parallel/test-http2-respond-file-404.js delete mode 100644 test/parallel/test-http2-respond-file-error-dir.js delete mode 100644 test/parallel/test-http2-server-errors.js diff --git a/doc/api/http2.md b/doc/api/http2.md index 57e1b74e7e..d9b8aa97b0 100755 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -1118,8 +1118,6 @@ added: v8.4.0 * `headers` {[Headers Object][]} * `options` {Object} * `statCheck` {Function} - * `onError` {Function} Callback function invoked in the case of an - Error before send * `getTrailers` {Function} Callback function invoked to collect trailer headers. * `offset` {number} The offset position at which to begin reading @@ -1148,16 +1146,6 @@ server.on('stream', (stream) => { function statCheck(stat, headers) { headers['last-modified'] = stat.mtime.toUTCString(); } - - function onError(err) { - if (err.code === 'ENOENT') { - stream.respond({ ':status': 404 }); - } else { - stream.respond({ ':status': 500 }); - } - stream.end(); - } - stream.respondWithFile('/some/file', { 'content-type': 'text/plain' }, { statCheck }); @@ -1190,10 +1178,6 @@ The `offset` and `length` options may be used to limit the response to a specific range subset. This can be used, for instance, to support HTTP Range requests. -The `options.onError` function may also be used to handle all the errors -that could happen before the delivery of the file is initiated. The -default behavior is to destroy the stream. - When set, the `options.getTrailers()` function is called immediately after queuing the last chunk of payload data to be sent. The callback is passed a single object (with a `null` prototype) that the listener may used to specify @@ -1224,19 +1208,6 @@ added: v8.4.0 * Extends: {net.Server} -In `Http2Server`, there is no `'clientError'` event as there is in -HTTP1. However, there are `'socketError'`, `'sessionError'`, and -`'streamError'`, for error happened on the socket, session or stream -respectively. - -#### Event: 'socketError' - - -The `'socketError'` event is emitted when a `'socketError'` event is emitted by -an `Http2Session` associated with the server. - #### Event: 'sessionError' -* `socket` {http2.ServerHttp2Stream} - -If an `ServerHttp2Stream` emits an `'error'` event, it will be forwarded here. -The stream will already be destroyed when this event is triggered. +The `'socketError'` event is emitted when a `'socketError'` event is emitted by +an `Http2Session` associated with the server. #### Event: 'stream'