From 30cc54275d570a804ced31843d1ff237dd701f85 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 30 May 2020 10:40:30 +0200 Subject: [PATCH 01/20] http: don't emit error after close Refs: https://github.com/nodejs/node/issues/33591 PR-URL: https://github.com/nodejs/node/pull/33654 Reviewed-By: James M Snell Reviewed-By: Matteo Collina --- lib/_http_client.js | 7 +++++- lib/_http_outgoing.js | 13 +++++++--- lib/_http_server.js | 3 +++ lib/internal/http.js | 1 + test/parallel/test-http-outgoing-destroy.js | 7 +----- test/parallel/test-http-outgoing-destroyed.js | 24 +++++++++++++++++++ .../test-http-server-write-after-end.js | 16 ++++++------- .../test-http-server-write-end-after-end.js | 18 ++++++++------ 8 files changed, 64 insertions(+), 25 deletions(-) create mode 100644 test/parallel/test-http-outgoing-destroyed.js diff --git a/lib/_http_client.js b/lib/_http_client.js index 3093047bd731f2..34ab5400207f45 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -49,7 +49,7 @@ const Agent = require('_http_agent'); const { Buffer } = require('buffer'); const { defaultTriggerAsyncIdScope } = require('internal/async_hooks'); const { URL, urlToOptions, searchParamsSymbol } = require('internal/url'); -const { kOutHeaders, kNeedDrain } = require('internal/http'); +const { kOutHeaders, kNeedDrain, kClosed } = require('internal/http'); const { connResetException, codes } = require('internal/errors'); const { ERR_HTTP_HEADERS_SENT, @@ -385,6 +385,7 @@ function _destroy(req, socket, err) { if (err) { req.emit('error', err); } + req[kClosed] = true; req.emit('close'); } } @@ -427,6 +428,7 @@ function socketCloseListener() { res.emit('error', connResetException('aborted')); } } + req[kClosed] = true; req.emit('close'); if (!res.aborted && res.readable) { res.on('end', function() { @@ -446,6 +448,7 @@ function socketCloseListener() { req.socket._hadError = true; req.emit('error', connResetException('socket hang up')); } + req[kClosed] = true; req.emit('close'); } @@ -550,6 +553,7 @@ function socketOnData(d) { req.emit(eventName, res, socket, bodyHead); req.destroyed = true; + req[kClosed] = true; req.emit('close'); } else { // Requested Upgrade or used CONNECT method, but have no handler. @@ -721,6 +725,7 @@ function requestOnPrefinish() { } function emitFreeNT(req) { + req[kClosed] = true; req.emit('close'); if (req.res) { req.res.emit('close'); diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index dade9a11014c01..0fa2a386eb17be 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -36,7 +36,7 @@ const assert = require('internal/assert'); const EE = require('events'); const Stream = require('stream'); const internalUtil = require('internal/util'); -const { kOutHeaders, utcDate, kNeedDrain } = require('internal/http'); +const { kOutHeaders, utcDate, kNeedDrain, kClosed } = require('internal/http'); const { Buffer } = require('buffer'); const common = require('_http_common'); const checkIsHttpToken = common._checkIsHttpToken; @@ -117,6 +117,7 @@ function OutgoingMessage() { this.finished = false; this._headerSent = false; this[kCorked] = 0; + this[kClosed] = false; this.socket = null; this._header = null; @@ -663,7 +664,9 @@ function onError(msg, err, callback) { function emitErrorNt(msg, err, callback) { callback(err); - if (typeof msg.emit === 'function') msg.emit('error', err); + if (typeof msg.emit === 'function' && !msg[kClosed]) { + msg.emit('error', err); + } } function write_(msg, chunk, encoding, callback, fromEnd) { @@ -690,7 +693,11 @@ function write_(msg, chunk, encoding, callback, fromEnd) { } if (err) { - onError(msg, err, callback); + if (!msg.destroyed) { + onError(msg, err, callback); + } else { + process.nextTick(callback, err); + } return false; } diff --git a/lib/_http_server.js b/lib/_http_server.js index f11c74ff7c4303..ee763daf889a28 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -49,6 +49,7 @@ const { OutgoingMessage } = require('_http_outgoing'); const { kOutHeaders, kNeedDrain, + kClosed, emitStatistics } = require('internal/http'); const { @@ -212,6 +213,7 @@ function onServerResponseClose() { // Fortunately, that requires only a single if check. :-) if (this._httpMessage) { this._httpMessage.destroyed = true; + this._httpMessage[kClosed] = true; this._httpMessage.emit('close'); } } @@ -729,6 +731,7 @@ function resOnFinish(req, res, socket, state, server) { function emitCloseNT(self) { self.destroyed = true; + self[kClosed] = true; self.emit('close'); } diff --git a/lib/internal/http.js b/lib/internal/http.js index aab4170a2f0e06..f7ed50d0c0f3cb 100644 --- a/lib/internal/http.js +++ b/lib/internal/http.js @@ -51,6 +51,7 @@ function emitStatistics(statistics) { module.exports = { kOutHeaders: Symbol('kOutHeaders'), kNeedDrain: Symbol('kNeedDrain'), + kClosed: Symbol('kClosed'), nowDate, utcDate, emitStatistics diff --git a/test/parallel/test-http-outgoing-destroy.js b/test/parallel/test-http-outgoing-destroy.js index 91c68aa9af3db0..47d5e948ab7970 100644 --- a/test/parallel/test-http-outgoing-destroy.js +++ b/test/parallel/test-http-outgoing-destroy.js @@ -10,13 +10,8 @@ const OutgoingMessage = http.OutgoingMessage; assert.strictEqual(msg.destroyed, false); msg.destroy(); assert.strictEqual(msg.destroyed, true); - let callbackCalled = false; msg.write('asd', common.mustCall((err) => { assert.strictEqual(err.code, 'ERR_STREAM_DESTROYED'); - callbackCalled = true; - })); - msg.on('error', common.mustCall((err) => { - assert.strictEqual(err.code, 'ERR_STREAM_DESTROYED'); - assert.strictEqual(callbackCalled, true); })); + msg.on('error', common.mustNotCall()); } diff --git a/test/parallel/test-http-outgoing-destroyed.js b/test/parallel/test-http-outgoing-destroyed.js new file mode 100644 index 00000000000000..e0199a1cd5ef23 --- /dev/null +++ b/test/parallel/test-http-outgoing-destroyed.js @@ -0,0 +1,24 @@ +'use strict'; +const common = require('../common'); +const http = require('http'); + +const server = http.createServer(common.mustCall((req, res) => { + req.pipe(res); + res.on('error', common.mustNotCall()); + res.on('close', common.mustCall(() => { + res.end('asd'); + process.nextTick(() => { + server.close(); + }); + })); +})).listen(0, () => { + http + .request({ + port: server.address().port, + method: 'PUT' + }) + .on('response', (res) => { + res.destroy(); + }) + .write('asd'); +}); diff --git a/test/parallel/test-http-server-write-after-end.js b/test/parallel/test-http-server-write-after-end.js index 589b673282c517..ba2877131227aa 100644 --- a/test/parallel/test-http-server-write-after-end.js +++ b/test/parallel/test-http-server-write-after-end.js @@ -8,19 +8,19 @@ const http = require('http'); const server = http.createServer(handle); function handle(req, res) { - res.on('error', common.mustCall((err) => { - common.expectsError({ - code: 'ERR_STREAM_WRITE_AFTER_END', - name: 'Error' - })(err); - server.close(); - })); + res.on('error', common.mustNotCall()); res.write('hello'); res.end(); setImmediate(common.mustCall(() => { - res.write('world'); + res.write('world', common.mustCall((err) => { + common.expectsError({ + code: 'ERR_STREAM_WRITE_AFTER_END', + name: 'Error' + })(err); + server.close(); + })); })); } diff --git a/test/parallel/test-http-server-write-end-after-end.js b/test/parallel/test-http-server-write-end-after-end.js index 37fbe062f12b69..02f86f611c1b8e 100644 --- a/test/parallel/test-http-server-write-end-after-end.js +++ b/test/parallel/test-http-server-write-end-after-end.js @@ -6,19 +6,23 @@ const http = require('http'); const server = http.createServer(handle); function handle(req, res) { - res.on('error', common.mustCall((err) => { - common.expectsError({ - code: 'ERR_STREAM_WRITE_AFTER_END', - name: 'Error' - })(err); - server.close(); - })); + res.on('error', common.mustNotCall()); res.write('hello'); res.end(); setImmediate(common.mustCall(() => { res.end('world'); + process.nextTick(() => { + server.close(); + }); + res.write('world', common.mustCall((err) => { + common.expectsError({ + code: 'ERR_STREAM_WRITE_AFTER_END', + name: 'Error' + })(err); + server.close(); + })); })); } From 51a2df4439ea23b5121fcb8e674eb7a3b144cdfa Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Sat, 20 Jun 2020 00:12:44 +0200 Subject: [PATCH 02/20] fs: document why isPerformingIO is required PR-URL: https://github.com/nodejs/node/pull/33982 Reviewed-By: Anna Henningsen Reviewed-By: Trivikram Kamat Reviewed-By: Ben Noordhuis Reviewed-By: Luigi Pinca --- lib/internal/fs/streams.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js index 9e6050139dc79a..0209f3e844c759 100644 --- a/lib/internal/fs/streams.js +++ b/lib/internal/fs/streams.js @@ -255,6 +255,12 @@ ReadStream.prototype._read = function(n) { }; ReadStream.prototype._destroy = function(err, cb) { + // Usually for async IO it is safe to close a file descriptor + // even when there are pending operations. However, due to platform + // differences file IO is implemented using synchronous operations + // running in a thread pool. Therefore, file descriptors are not safe + // to close while used in a pending read or write operation. Wait for + // any pending IO (kIsPerformingIO) to complete (kIoDone). if (this[kIsPerformingIO]) { this.once(kIoDone, (er) => close(this, err || er, cb)); } else { @@ -416,12 +422,19 @@ WriteStream.prototype._writev = function(data, cb) { }; WriteStream.prototype._destroy = function(err, cb) { + // Usually for async IO it is safe to close a file descriptor + // even when there are pending operations. However, due to platform + // differences file IO is implemented using synchronous operations + // running in a thread pool. Therefore, file descriptors are not safe + // to close while used in a pending read or write operation. Wait for + // any pending IO (kIsPerformingIO) to complete (kIoDone). if (this[kIsPerformingIO]) { this.once(kIoDone, (er) => close(this, err || er, cb)); } else { close(this, err, cb); } }; + WriteStream.prototype.close = function(cb) { if (cb) { if (this.closed) { From 64d22c320c67255b42c8185a333a92a499c95820 Mon Sep 17 00:00:00 2001 From: Denys Otrishko Date: Thu, 18 Jun 2020 22:58:42 +0300 Subject: [PATCH 03/20] timers: fix multipleResolves in promisified timeouts/immediates After successful timer finish the abort event callback would still reject (already resolved promise) upon calling abortController.abort(). Signed-off-by: Denys Otrishko PR-URL: https://github.com/nodejs/node/pull/33949 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Anna Henningsen --- lib/timers.js | 12 ++++++++---- test/parallel/test-timers-promisified.js | 19 +++++++++++++++++++ 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/lib/timers.js b/lib/timers.js index fce904019205e9..53e934f3c9ac7c 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -190,8 +190,10 @@ setTimeout[customPromisify] = function(after, value, options = {}) { insert(timeout, timeout._idleTimeout); if (signal) { signal.addEventListener('abort', () => { - clearTimeout(timeout); - reject(lazyDOMException('AbortError')); + if (!timeout._destroyed) { + clearTimeout(timeout); + reject(lazyDOMException('AbortError')); + } }, { once: true }); } }); @@ -340,8 +342,10 @@ setImmediate[customPromisify] = function(value, options = {}) { const immediate = new Immediate(resolve, [value]); if (signal) { signal.addEventListener('abort', () => { - clearImmediate(immediate); - reject(lazyDOMException('AbortError')); + if (!immediate._destroyed) { + clearImmediate(immediate); + reject(lazyDOMException('AbortError')); + } }, { once: true }); } }); diff --git a/test/parallel/test-timers-promisified.js b/test/parallel/test-timers-promisified.js index d470d2f97c79eb..f46dc3f24d20eb 100644 --- a/test/parallel/test-timers-promisified.js +++ b/test/parallel/test-timers-promisified.js @@ -10,6 +10,8 @@ const { promisify } = require('util'); const setTimeout = promisify(timers.setTimeout); const setImmediate = promisify(timers.setImmediate); +process.on('multipleResolves', common.mustNotCall()); + { const promise = setTimeout(1); promise.then(common.mustCall((value) => { @@ -66,6 +68,23 @@ const setImmediate = promisify(timers.setImmediate); assert.rejects(setImmediate(10, { signal }), /AbortError/); } +{ + // Check that aborting after resolve will not reject. + const ac = new AbortController(); + const signal = ac.signal; + setTimeout(10, undefined, { signal }).then(() => { + ac.abort(); + }); +} +{ + // Check that aborting after resolve will not reject. + const ac = new AbortController(); + const signal = ac.signal; + setImmediate(10, { signal }).then(() => { + ac.abort(); + }); +} + { Promise.all( [1, '', false, Infinity].map((i) => assert.rejects(setImmediate(10, i)), { From 7a5d3a2fc1915166b1da2c161f020358a8c36bfd Mon Sep 17 00:00:00 2001 From: rickyes Date: Thu, 28 May 2020 23:15:55 +0800 Subject: [PATCH 04/20] http: add maxTotalSockets to agent class Add maxTotalSockets to determine how many sockets an agent can open. Unlike maxSockets, The maxTotalSockets does not count by per origin. PR-URL: https://github.com/nodejs/node/pull/33617 Fixes: https://github.com/nodejs/node/issues/31942 Reviewed-By: Robert Nagy Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- doc/api/http.md | 10 ++ lib/_http_agent.js | 52 +++++++- .../test-http-agent-maxtotalsockets.js | 113 ++++++++++++++++++ 3 files changed, 171 insertions(+), 4 deletions(-) create mode 100644 test/parallel/test-http-agent-maxtotalsockets.js diff --git a/doc/api/http.md b/doc/api/http.md index b48874c9fcec21..c3e2d016608aed 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -300,6 +300,16 @@ added: v0.3.6 By default set to `Infinity`. Determines how many concurrent sockets the agent can have open per origin. Origin is the returned value of [`agent.getName()`][]. +### `agent.maxTotalSockets` + + +* {number} + +By default set to `Infinity`. Determines how many concurrent sockets the agent +can have open. Unlike `maxSockets`, this parameter applies across all origins. + ### `agent.requests` From f05c963f3347e9a0702a342cc1572cf3c3ee77f3 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 19 Jun 2020 19:46:47 -0700 Subject: [PATCH 06/20] doc: change "GitHub Repo" to "Code repository" "GitHub Repo & Issue Tracker" changed to "Code repository and issue tracker". PR-URL: https://github.com/nodejs/node/pull/33985 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Matheus Marchini Reviewed-By: Gus Caplan Reviewed-By: Myles Borins --- doc/api/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/index.md b/doc/api/index.md index 0947c72c5d863f..7d4c85593b43a6 100644 --- a/doc/api/index.md +++ b/doc/api/index.md @@ -65,4 +65,4 @@
-* [GitHub Repo & Issue Tracker](https://github.com/nodejs/node) +* [Code repository and issue tracker](https://github.com/nodejs/node) From 07b2ada00decf1dacd49e76370d9e4a4d929de92 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 19 Jun 2020 21:15:40 -0700 Subject: [PATCH 07/20] doc: fix lexical sorting of bottom-references in dns doc The links are sorted in lexical order except for the two RFC links which are reversed. Fix that. PR-URL: https://github.com/nodejs/node/pull/33987 Reviewed-By: Richard Lau Reviewed-By: Luigi Pinca --- doc/api/dns.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/dns.md b/doc/api/dns.md index 909d237f6777b9..20df48c5060a9e 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -1201,6 +1201,6 @@ uses. For instance, _they do not use the configuration from `/etc/hosts`_. [DNS error codes]: #dns_error_codes [Domain Name System (DNS)]: https://en.wikipedia.org/wiki/Domain_Name_System [Implementation considerations section]: #dns_implementation_considerations -[RFC 8482]: https://tools.ietf.org/html/rfc8482 [RFC 5952]: https://tools.ietf.org/html/rfc5952#section-6 +[RFC 8482]: https://tools.ietf.org/html/rfc8482 [supported `getaddrinfo` flags]: #dns_supported_getaddrinfo_flags From 122038c6a2334a3da8ffbaa824bb3c3f61ab8197 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 17 Jun 2020 11:11:09 +0200 Subject: [PATCH 08/20] build: add target specific build_type variable This commit add a target specific variable named 'build_type' to the node and node_g targets. The motivation for doing this is that both targets share the same prerequisites, and the recepies are the same (apart from the build type) so some duplication can be avoided. PR-URL: https://github.com/nodejs/node/pull/33925 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- Makefile | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 7fa645f21dd9c9..89cd8f68885865 100644 --- a/Makefile +++ b/Makefile @@ -98,13 +98,12 @@ help: ## Print help for targets with comments. # and recreated which can break the addons build when running test-ci # See comments on the build-addons target for some more info ifeq ($(BUILD_WITH), make) -$(NODE_EXE): config.gypi out/Makefile - $(MAKE) -C out BUILDTYPE=Release V=$(V) - if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Release/$(NODE_EXE) $@; fi - -$(NODE_G_EXE): config.gypi out/Makefile - $(MAKE) -C out BUILDTYPE=Debug V=$(V) - if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi +$(NODE_EXE): build_type:=Release +$(NODE_G_EXE): build_type:=Debug +$(NODE_EXE) $(NODE_G_EXE): config.gypi out/Makefile + $(MAKE) -C out BUILDTYPE=${build_type} V=$(V) + if [ ! -r $@ -o ! -L $@ ]; then \ + ln -fs out/${build_type}/$(NODE_EXE) $@; fi else ifeq ($(BUILD_WITH), ninja) ifeq ($(V),1) From 54374d4343f47677aea2a288e9bf8b5fd1cda90a Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 16 Jun 2020 13:18:42 +0200 Subject: [PATCH 09/20] src: remove unnecessary ToLocalChecked call MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33902 Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso Reviewed-By: Richard Lau Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- src/node_contextify.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 536d761c637928..4dcb65bd85a0eb 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -1122,14 +1122,14 @@ void ContextifyContext::CompileFunction( context_extensions.size(), context_extensions.data(), options, v8::ScriptCompiler::NoCacheReason::kNoCacheNoReason, &script); - if (maybe_fn.IsEmpty()) { + Local fn; + if (!maybe_fn.ToLocal(&fn)) { if (try_catch.HasCaught() && !try_catch.HasTerminated()) { errors::DecorateErrorStack(env, try_catch); try_catch.ReThrow(); } return; } - Local fn = maybe_fn.ToLocalChecked(); Local cache_key; if (!env->compiled_fn_entry_template()->NewInstance( From b8ea47162d84ade96698cb45a0de5c0dd9959251 Mon Sep 17 00:00:00 2001 From: Alba Mendez Date: Fri, 12 Jun 2020 13:25:04 +0200 Subject: [PATCH 10/20] doc: warn that tls.connect() doesn't set SNI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a note warning users that when using tls.connect(), the `servername` option must be set explicitely to enable SNI, otherwise the connection could fail. PR-URL: https://github.com/nodejs/node/pull/33855 Fixes: https://github.com/nodejs/node/issues/28167 Co-authored-by: Denys Otrishko Reviewed-By: Robert Nagy Reviewed-By: Denys Otrishko Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- doc/api/tls.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/api/tls.md b/doc/api/tls.md index e294a75f919a3d..9b06fde493e6a2 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -1399,6 +1399,12 @@ The `callback` function, if specified, will be added as a listener for the `tls.connect()` returns a [`tls.TLSSocket`][] object. +Unlike the `https` API, `tls.connect()` does not enable the +SNI (Server Name Indication) extension by default, which may cause some +servers to return an incorrect certificate or reject the connection +altogether. To enable SNI, set the `servername` option in addition +to `host`. + The following illustrates a client for the echo server example from [`tls.createServer()`][]: From 9743624c0b872a50a14df862381c460ac7b3fd92 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Fri, 19 Jun 2020 22:17:34 +0800 Subject: [PATCH 11/20] quic: fix typo in comments PR-URL: https://github.com/nodejs/node/pull/33975 Reviewed-By: Richard Lau Reviewed-By: Anna Henningsen Reviewed-By: David Carlier Reviewed-By: James M Snell Reviewed-By: Gus Caplan Reviewed-By: Trivikram Kamat --- src/quic/node_quic_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quic/node_quic_util.h b/src/quic/node_quic_util.h index e1490941aa3224..d698a6df0b4041 100644 --- a/src/quic/node_quic_util.h +++ b/src/quic/node_quic_util.h @@ -114,7 +114,7 @@ class StatsBase { // A StatsBase instance may have one of three histogram // instances. One that records rate of data flow, one // that records size of data chunk, and one that records - // rate of data ackwowledgement. These may be used in + // rate of data acknowledgement. These may be used in // slightly different ways of different StatsBase // instances or may be turned off entirely. enum HistogramOptions { From 09330fc1557010fce528ce3299adc69b61ee5d97 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Fri, 19 Jun 2020 22:39:47 +0800 Subject: [PATCH 12/20] quic: fix clang-tidy performance-faster-string-find issue PR-URL: https://github.com/nodejs/node/pull/33975 Reviewed-By: Richard Lau Reviewed-By: Anna Henningsen Reviewed-By: David Carlier Reviewed-By: James M Snell Reviewed-By: Gus Caplan Reviewed-By: Trivikram Kamat --- src/quic/node_quic_crypto.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quic/node_quic_crypto.cc b/src/quic/node_quic_crypto.cc index 4b4ec901001f40..560c806917199f 100644 --- a/src/quic/node_quic_crypto.cc +++ b/src/quic/node_quic_crypto.cc @@ -384,7 +384,7 @@ bool CheckCertNames( return false; } - if (name_parts[0].find("*") == std::string::npos || + if (name_parts[0].find('*') == std::string::npos || name_parts[0].find("xn--") != std::string::npos) { return host_parts[0] == name_parts[0]; } From 25413b003c574b0b070141dd8931e1a7cab77131 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Sat, 20 Jun 2020 00:51:30 +0800 Subject: [PATCH 13/20] src: improve indention for upd_wrap.cc PR-URL: https://github.com/nodejs/node/pull/33976 Reviewed-By: David Carlier Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- src/udp_wrap.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/udp_wrap.cc b/src/udp_wrap.cc index 24df0acba46041..26bafebcb22c14 100644 --- a/src/udp_wrap.cc +++ b/src/udp_wrap.cc @@ -230,12 +230,12 @@ int sockaddr_for_family(int address_family, const unsigned short port, struct sockaddr_storage* addr) { switch (address_family) { - case AF_INET: - return uv_ip4_addr(address, port, reinterpret_cast(addr)); - case AF_INET6: - return uv_ip6_addr(address, port, reinterpret_cast(addr)); - default: - CHECK(0 && "unexpected address family"); + case AF_INET: + return uv_ip4_addr(address, port, reinterpret_cast(addr)); + case AF_INET6: + return uv_ip6_addr(address, port, reinterpret_cast(addr)); + default: + CHECK(0 && "unexpected address family"); } } From 74cd70e568dafefdf16845e2e7738d053456d290 Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Sat, 20 Jun 2020 00:57:27 +0800 Subject: [PATCH 14/20] test: fix typo in common/index.js PR-URL: https://github.com/nodejs/node/pull/33976 Reviewed-By: David Carlier Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- test/common/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common/index.js b/test/common/index.js index 9de81b426e6c7e..33754760917acd 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -27,7 +27,7 @@ const process = global.process; // Some tests tamper with the process global. const assert = require('assert'); const { exec, execSync, spawnSync } = require('child_process'); const fs = require('fs'); -// Do not require 'os' until needed so that test-os-checked-fucnction can +// Do not require 'os' until needed so that test-os-checked-function can // monkey patch it. If 'os' is required here, that test will fail. const path = require('path'); const util = require('util'); From 326a79ebb979de1a952a83c23d37bbdcd6cdc2eb Mon Sep 17 00:00:00 2001 From: gengjiawen Date: Sat, 20 Jun 2020 00:58:23 +0800 Subject: [PATCH 15/20] test: fix typo in test-quic-client-empty-preferred-address.js PR-URL: https://github.com/nodejs/node/pull/33976 Reviewed-By: David Carlier Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- test/parallel/test-quic-client-empty-preferred-address.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-quic-client-empty-preferred-address.js b/test/parallel/test-quic-client-empty-preferred-address.js index fa5a0b65503af4..a65b9f9032fc98 100644 --- a/test/parallel/test-quic-client-empty-preferred-address.js +++ b/test/parallel/test-quic-client-empty-preferred-address.js @@ -3,7 +3,7 @@ // This test ensures that when we don't define `preferredAddress` // on the server while the `preferredAddressPolicy` on the client -// is `accpet`, it works as expected. +// is `accept`, it works as expected. const common = require('../common'); if (!common.hasQuic) From 013cd1ac6f6f91d70ad21012aa2bdc785955c0c1 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Thu, 18 Jun 2020 06:23:55 +0200 Subject: [PATCH 16/20] quic: use Check instead of FromJust in node_quic.cc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33937 Reviewed-By: Tobias Nießen Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- src/quic/node_quic.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/quic/node_quic.cc b/src/quic/node_quic.cc index 9223694643554b..4f1d3e128dd38b 100644 --- a/src/quic/node_quic.cc +++ b/src/quic/node_quic.cc @@ -125,7 +125,7 @@ void Initialize(Local target, #define SET_STATE_TYPEDARRAY(name, field) \ target->Set(context, \ FIXED_ONE_BYTE_STRING(isolate, (name)), \ - (field.GetJSArray())).FromJust() + (field.GetJSArray())).Check() SET_STATE_TYPEDARRAY("sessionConfig", state->quicsessionconfig_buffer); SET_STATE_TYPEDARRAY("http3Config", state->http3config_buffer); #undef SET_STATE_TYPEDARRAY From 73a7a24ccedded80c0eadf1232428438f4c95080 Mon Sep 17 00:00:00 2001 From: Shakil-Shahadat Date: Wed, 10 Jun 2020 06:15:31 +0600 Subject: [PATCH 17/20] doc: update fs.md First class heading is made to look like other headings. PR-URL: https://github.com/nodejs/node/pull/33820 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil --- doc/api/fs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index db71979df7f882..a2dbdcc668b0f2 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -284,7 +284,7 @@ synchronous use libuv's threadpool, which can have surprising and negative performance implications for some applications. See the [`UV_THREADPOOL_SIZE`][] documentation for more information. -## Class `fs.Dir` +## Class: `fs.Dir` From 680644ae153cd2ef6817e0df88db50fb64ab5c36 Mon Sep 17 00:00:00 2001 From: wenningplus Date: Tue, 9 Jun 2020 13:42:07 +0800 Subject: [PATCH 18/20] http: expose host and protocol on ClientRequest Allow host and protocol to be inspected. PR-URL: https://github.com/nodejs/node/pull/33803 Fixes: https://github.com/nodejs/node/issues/2461 Reviewed-By: Robert Nagy Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell --- doc/api/http.md | 21 +++++++++++++++++ lib/_http_client.js | 2 ++ .../parallel/test-http-outgoing-properties.js | 23 +++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/doc/api/http.md b/doc/api/http.md index c3e2d016608aed..93390c9b35fa63 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -754,6 +754,27 @@ added: v0.4.0 * {string} The request path. +### `request.method` + + +* {string} The request method. + +### `request.host` + + +* {string} The request host. + +### `request.protocol` + + +* {string} The request protocol. + ### `request.removeHeader(name)`