From 17ee4c5113d4d94fba51a463afa3f5f1fcec4a09 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Wed, 10 Jan 2018 09:48:21 -0800 Subject: [PATCH 1/2] doc: update pushStream docs to use err first Refs: https://github.com/nodejs/node/pull/17406#issuecomment-356661798 --- doc/api/http2.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/api/http2.md b/doc/api/http2.md index 09bce9d144d02a..c008a130915a46 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -1174,14 +1174,16 @@ added: v8.4.0 * Returns: {undefined} Initiates a push stream. The callback is invoked with the new `Http2Stream` -instance created for the push stream. +instance created for the push stream passed as the second argument, or an +`Error` passed as the first argument. ```js const http2 = require('http2'); const server = http2.createServer(); server.on('stream', (stream) => { stream.respond({ ':status': 200 }); - stream.pushStream({ ':path': '/' }, (pushStream) => { + stream.pushStream({ ':path': '/' }, (err, pushStream) => { + if (err) throw err; pushStream.respond({ ':status': 200 }); pushStream.end('some pushed data'); }); From ca573f23e2b500bc76bc6a08107049ee87a8d540 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 11 Jan 2018 10:05:15 -0800 Subject: [PATCH 2/2] doc: fix s/rstStream/close in example --- doc/api/http2.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/http2.md b/doc/api/http2.md index c008a130915a46..f07c5fb0917b6e 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -1015,7 +1015,7 @@ const { NGHTTP2_CANCEL } = http2.constants; const req = client.request({ ':path': '/' }); // Cancel the stream if there's no activity after 5 seconds -req.setTimeout(5000, () => req.rstStream(NGHTTP2_CANCEL)); +req.setTimeout(5000, () => req.close(NGHTTP2_CANCEL)); ``` #### http2stream.state