From 03ddd13d8a72190aa22194eb535e9cb683f4f815 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Wed, 7 Feb 2018 01:36:20 +0100 Subject: [PATCH 01/47] net: use `_final` instead of `on('finish')` Shutting down the connection is what `_final` is there for. PR-URL: https://github.com/nodejs/node/pull/18608 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Matteo Collina --- lib/internal/streams/destroy.js | 2 ++ lib/net.js | 28 +++++++++++-------- test/async-hooks/test-shutdownwrap.js | 12 ++++---- test/parallel/test-stream-writable-destroy.js | 14 ++++++++++ 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/lib/internal/streams/destroy.js b/lib/internal/streams/destroy.js index 86a22633f2f..985332ac460 100644 --- a/lib/internal/streams/destroy.js +++ b/lib/internal/streams/destroy.js @@ -55,6 +55,8 @@ function undestroy() { this._writableState.destroyed = false; this._writableState.ended = false; this._writableState.ending = false; + this._writableState.finalCalled = false; + this._writableState.prefinished = false; this._writableState.finished = false; this._writableState.errorEmitted = false; } diff --git a/lib/net.js b/lib/net.js index ed2ea2dc277..edf8a6c0bc5 100644 --- a/lib/net.js +++ b/lib/net.js @@ -256,7 +256,6 @@ function Socket(options) { } // shut down the socket when we're finished with it. - this.on('finish', onSocketFinish); this.on('_socketEnd', onSocketEnd); initSocketHandle(this); @@ -303,39 +302,42 @@ Socket.prototype._unrefTimer = function _unrefTimer() { function shutdownSocket(self, callback) { var req = new ShutdownWrap(); - req.oncomplete = callback; + req.oncomplete = afterShutdown; req.handle = self._handle; + req.callback = callback; return self._handle.shutdown(req); } // the user has called .end(), and all the bytes have been // sent out to the other side. -function onSocketFinish() { - // If still connecting - defer handling 'finish' until 'connect' will happen +Socket.prototype._final = function(cb) { + // If still connecting - defer handling `_final` until 'connect' will happen if (this.connecting) { - debug('osF: not yet connected'); - return this.once('connect', onSocketFinish); + debug('_final: not yet connected'); + return this.once('connect', () => this._final(cb)); } - debug('onSocketFinish'); if (!this.readable || this._readableState.ended) { - debug('oSF: ended, destroy', this._readableState); + debug('_final: ended, destroy', this._readableState); + cb(); return this.destroy(); } - debug('oSF: not ended, call shutdown()'); + debug('_final: not ended, call shutdown()'); // otherwise, just shutdown, or destroy() if not possible - if (!this._handle || !this._handle.shutdown) + if (!this._handle || !this._handle.shutdown) { + cb(); return this.destroy(); + } var err = defaultTriggerAsyncIdScope( - this[async_id_symbol], shutdownSocket, this, afterShutdown + this[async_id_symbol], shutdownSocket, this, cb ); if (err) return this.destroy(errnoException(err, 'shutdown')); -} +}; function afterShutdown(status, handle) { @@ -344,6 +346,8 @@ function afterShutdown(status, handle) { debug('afterShutdown destroyed=%j', self.destroyed, self._readableState); + this.callback(); + // callback may come after call to destroy. if (self.destroyed) return; diff --git a/test/async-hooks/test-shutdownwrap.js b/test/async-hooks/test-shutdownwrap.js index dfaac2a1c05..fea4a3a166a 100644 --- a/test/async-hooks/test-shutdownwrap.js +++ b/test/async-hooks/test-shutdownwrap.js @@ -24,11 +24,13 @@ let endedConnection = false; function onconnection(c) { assert.strictEqual(hooks.activitiesOfTypes('SHUTDOWNWRAP').length, 0); c.end(); - endedConnection = true; - const as = hooks.activitiesOfTypes('SHUTDOWNWRAP'); - assert.strictEqual(as.length, 1); - checkInvocations(as[0], { init: 1 }, 'after ending client connection'); - this.close(onserverClosed); + process.nextTick(() => { + endedConnection = true; + const as = hooks.activitiesOfTypes('SHUTDOWNWRAP'); + assert.strictEqual(as.length, 1); + checkInvocations(as[0], { init: 1 }, 'after ending client connection'); + this.close(onserverClosed); + }); } function onconnected() { diff --git a/test/parallel/test-stream-writable-destroy.js b/test/parallel/test-stream-writable-destroy.js index 87e55eccc3f..46c48511177 100644 --- a/test/parallel/test-stream-writable-destroy.js +++ b/test/parallel/test-stream-writable-destroy.js @@ -185,3 +185,17 @@ const { inherits } = require('util'); assert.strictEqual(expected, err); })); } + +{ + // Checks that `._undestroy()` restores the state so that `final` will be + // called again. + const write = new Writable({ + write: common.mustNotCall(), + final: common.mustCall((cb) => cb(), 2) + }); + + write.end(); + write.destroy(); + write._undestroy(); + write.end(); +} From 15e02ceb1e7522c27f586bad878cdddc613fcada Mon Sep 17 00:00:00 2001 From: Trivikram <16024985+trivikr@users.noreply.github.com> Date: Sun, 18 Feb 2018 00:11:06 -0800 Subject: [PATCH 02/47] test: http2 errors on req.close() PR-URL: https://github.com/nodejs/node/pull/18854 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- ...t-http2-client-rststream-before-connect.js | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-http2-client-rststream-before-connect.js b/test/parallel/test-http2-client-rststream-before-connect.js index 10d7520ac12..01e0561c3a2 100644 --- a/test/parallel/test-http2-client-rststream-before-connect.js +++ b/test/parallel/test-http2-client-rststream-before-connect.js @@ -16,18 +16,30 @@ server.on('stream', (stream) => { server.listen(0, common.mustCall(() => { const client = h2.connect(`http://localhost:${server.address().port}`); const req = client.request(); - req.close(1); + const closeCode = 1; + + common.expectsError( + () => req.close(2 ** 32), + { + type: RangeError, + code: 'ERR_OUT_OF_RANGE', + message: 'The value of "code" is out of range.' + } + ); + assert.strictEqual(req.closed, false); + + req.close(closeCode, common.mustCall()); assert.strictEqual(req.closed, true); // Make sure that destroy is called. req._destroy = common.mustCall(req._destroy.bind(req)); // Second call doesn't do anything. - req.close(8); + req.close(closeCode + 1); req.on('close', common.mustCall((code) => { assert.strictEqual(req.destroyed, true); - assert.strictEqual(code, 1); + assert.strictEqual(code, closeCode); server.close(); client.close(); })); @@ -35,7 +47,7 @@ server.listen(0, common.mustCall(() => { req.on('error', common.expectsError({ code: 'ERR_HTTP2_STREAM_ERROR', type: Error, - message: 'Stream closed with error code 1' + message: `Stream closed with error code ${closeCode}` })); req.on('response', common.mustCall()); From ab7c627e5327d621a734a32680cbfc99453f8b20 Mon Sep 17 00:00:00 2001 From: Yihong Wang Date: Thu, 15 Feb 2018 13:39:13 -0800 Subject: [PATCH 03/47] test: check symbols in shared lib When building the node with `--shared` option, we need to verify the symbols in shared lib instead of executable. Refs: https://github.com/nodejs/node/issues/18535 Signed-off-by: Yihong Wang PR-URL: https://github.com/nodejs/node/pull/18806 Refs: https://github.com/nodejs/node/issues/18535 Reviewed-By: Richard Lau Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig Reviewed-By: Gibson Fahnestock Reviewed-By: Yuta Hiroto Reviewed-By: Anna Henningsen --- test/common/shared-lib-util.js | 16 +++++++++++++++- test/parallel/test-postmortem-metadata.js | 8 +++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/test/common/shared-lib-util.js b/test/common/shared-lib-util.js index 5699c4f74c6..963c6ee1391 100644 --- a/test/common/shared-lib-util.js +++ b/test/common/shared-lib-util.js @@ -1,5 +1,5 @@ -/* eslint-disable node-core/required-modules */ 'use strict'; +const common = require('../common'); const path = require('path'); // If node executable is linked to shared lib, need to take care about the @@ -27,3 +27,17 @@ exports.addLibraryPath = function(env) { (env.PATH ? env.PATH + path.delimiter : '') + path.dirname(process.execPath); }; + +// Get the full path of shared lib +exports.getSharedLibPath = function() { + if (common.isWindows) { + return path.join(path.dirname(process.execPath), 'node.dll'); + } else if (common.isOSX) { + return path.join(path.dirname(process.execPath), + `libnode.${process.config.variables.shlib_suffix}`); + } else { + return path.join(path.dirname(process.execPath), + 'lib.target', + `libnode.${process.config.variables.shlib_suffix}`); + } +}; diff --git a/test/parallel/test-postmortem-metadata.js b/test/parallel/test-postmortem-metadata.js index 72a65d32a61..0438f7fccb7 100644 --- a/test/parallel/test-postmortem-metadata.js +++ b/test/parallel/test-postmortem-metadata.js @@ -7,7 +7,13 @@ const common = require('../common'); const assert = require('assert'); const { spawnSync } = require('child_process'); -const args = [process.execPath]; +const { getSharedLibPath } = require('../common/shared-lib-util.js'); + +// For shared lib case, check shared lib instead +const args = [ + process.config.variables.node_shared ? + getSharedLibPath() : process.execPath +]; if (common.isAIX) args.unshift('-Xany', '-B'); From 48e90ed87e3116333f0b964a2eed352ca915a660 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Tue, 20 Feb 2018 01:42:14 +0200 Subject: [PATCH 04/47] doc: lowercase primitives in test/common/README.md PR-URL: https://github.com/nodejs/node/pull/18875 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Ruben Bridgewater Reviewed-By: Joyee Cheung Reviewed-By: Luigi Pinca --- test/common/README.md | 156 +++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 78 deletions(-) diff --git a/test/common/README.md b/test/common/README.md index daf295855b8..01064a7a8b7 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -21,7 +21,7 @@ The `benchmark` module is used by tests to run benchmarks. ### runBenchmark(name, args, env) -* `name` [<String>] Name of benchmark suite to be run. +* `name` [<string>] Name of benchmark suite to be run. * `args` [<Array>] Array of environment variable key/value pairs (ex: `n=1`) to be applied via `--set`. * `env` [<Object>] Environment variables to be applied during the run. @@ -41,12 +41,12 @@ Takes `whitelist` and concats that with predefined `knownGlobals`. A stream to push an array into a REPL ### busyLoop(time) -* `time` [<Number>] +* `time` [<number>] Blocks for `time` amount of time. ### canCreateSymLink() -* return [<Boolean>] +* return [<boolean>] Checks whether the current running process can create symlinks. On Windows, this returns `false` if the process running doesn't have privileges to create @@ -67,7 +67,7 @@ failures. Platform normalizes the `dd` command ### enoughTestMem -* [<Boolean>] +* [<boolean>] Indicates if there is more than 1gb of total memory. @@ -76,17 +76,17 @@ Indicates if there is more than 1gb of total memory. * `settings` [<Object>] that must contain the `code` property plus any of the other following properties (some properties only apply for `AssertionError`): - * `code` [<String>] + * `code` [<string>] expected error must have this value for its `code` property. * `type` [<Function>] expected error must be an instance of `type` and must be an Error subclass. - * `message` [<String>] or [<RegExp>] + * `message` [<string>] or [<RegExp>] if a string is provided for `message`, expected error must have it for its `message` property; if a regular expression is provided for `message`, the regular expression must match the `message` property of the expected error. - * `name` [<String>] + * `name` [<string>] expected error must have this value for its `name` property. - * `generatedMessage` [<String>] + * `generatedMessage` [<string>] (`AssertionError` only) expected error must have this value for its `generatedMessage` property. * `actual` <any> @@ -98,7 +98,7 @@ Indicates if there is more than 1gb of total memory. * `operator` <any> (`AssertionError` only) expected error must have this value for its `operator` property. -* `exact` [<Number>] default = 1 +* `exact` [<number>] default = 1 * return [<Function>] If `fn` is provided, it will be passed to `assert.throws` as first argument @@ -109,14 +109,14 @@ Indicates if there is more than 1gb of total memory. test is complete, then the test will fail. ### expectWarning(name, expected) -* `name` [<String>] -* `expected` [<String>] | [<Array>] +* `name` [<string>] +* `expected` [<string>] | [<Array>] Tests whether `name` and `expected` are part of a raised warning. ### fileExists(pathname) -* pathname [<String>] -* return [<Boolean>] +* pathname [<string>] +* return [<boolean>] Checks if `pathname` exists @@ -135,42 +135,42 @@ consisting of all `ArrayBufferView` and an `ArrayBuffer`. ### getCallSite(func) * `func` [<Function>] -* return [<String>] +* return [<string>] Returns the file name and line number for the provided Function. ### globalCheck -* [<Boolean>] +* [<boolean>] Set to `false` if the test should not check for global leaks. ### hasCrypto -* [<Boolean>] +* [<boolean>] Indicates whether OpenSSL is available. ### hasFipsCrypto -* [<Boolean>] +* [<boolean>] Indicates `hasCrypto` and `crypto` with fips. ### hasIntl -* [<Boolean>] +* [<boolean>] Indicates if [internationalization] is supported. ### hasSmallICU -* [<Boolean>] +* [<boolean>] Indicates `hasIntl` and `small-icu` are supported. ### hasIPv6 -* [<Boolean>] +* [<boolean>] Indicates whether `IPv6` is supported on this platform. ### hasMultiLocalhost -* [<Boolean>] +* [<boolean>] Indicates if there are multiple localhosts available. @@ -193,58 +193,58 @@ be passed to `listener`. What's more, `process.stdout.writeTimes` is a count of the number of calls. ### inFreeBSDJail -* [<Boolean>] +* [<boolean>] Checks whether free BSD Jail is true or false. ### isAIX -* [<Boolean>] +* [<boolean>] Platform check for Advanced Interactive eXecutive (AIX). ### isAlive(pid) -* `pid` [<Number>] -* return [<Boolean>] +* `pid` [<number>] +* return [<boolean>] Attempts to 'kill' `pid` ### isFreeBSD -* [<Boolean>] +* [<boolean>] Platform check for Free BSD. ### isLinux -* [<Boolean>] +* [<boolean>] Platform check for Linux. ### isLinuxPPCBE -* [<Boolean>] +* [<boolean>] Platform check for Linux on PowerPC. ### isOSX -* [<Boolean>] +* [<boolean>] Platform check for macOS. ### isSunOS -* [<Boolean>] +* [<boolean>] Platform check for SunOS. ### isWindows -* [<Boolean>] +* [<boolean>] Platform check for Windows. ### isWOW64 -* [<Boolean>] +* [<boolean>] Platform check for Windows 32-bit on Windows 64-bit. ### isCPPSymbolsNotMapped -* [<Boolean>] +* [<boolean>] Platform check for C++ symbols are mapped or not. @@ -254,7 +254,7 @@ Platform check for C++ symbols are mapped or not. Indicates whether any globals are not on the `knownGlobals` list. ### localhostIPv4 -* [<String>] +* [<string>] IP of `localhost`. @@ -265,7 +265,7 @@ Array of IPV6 representations for `localhost`. ### mustCall([fn][, exact]) * `fn` [<Function>] default = () => {} -* `exact` [<Number>] default = 1 +* `exact` [<number>] default = 1 * return [<Function>] Returns a function that calls `fn`. If the returned function has not been called @@ -276,7 +276,7 @@ If `fn` is not provided, an empty function will be used. ### mustCallAsync([fn][, exact]) * `fn` [<Function>] -* `exact` [<Number>] default = 1 +* `exact` [<number>] default = 1 * return [<Function>] The same as `mustCall()`, except that it is also checked that the Promise @@ -287,7 +287,7 @@ function, if necessary wrapped as a promise. ### mustCallAtLeast([fn][, minimum]) * `fn` [<Function>] default = () => {} -* `minimum` [<Number>] default = 1 +* `minimum` [<number>] default = 1 * return [<Function>] Returns a function that calls `fn`. If the returned function has not been called @@ -297,44 +297,44 @@ fail. If `fn` is not provided, an empty function will be used. ### mustNotCall([msg]) -* `msg` [<String>] default = 'function should not have been called' +* `msg` [<string>] default = 'function should not have been called' * return [<Function>] Returns a function that triggers an `AssertionError` if it is invoked. `msg` is used as the error message for the `AssertionError`. ### nodeProcessAborted(exitCode, signal) -* `exitCode` [<Number>] -* `signal` [<String>] -* return [<Boolean>] +* `exitCode` [<number>] +* `signal` [<string>] +* return [<boolean>] Returns `true` if the exit code `exitCode` and/or signal name `signal` represent the exit code and/or signal name of a node process that aborted, `false` otherwise. ### opensslCli -* [<Boolean>] +* [<boolean>] Indicates whether 'opensslCli' is supported. ### platformTimeout(ms) -* `ms` [<Number>] -* return [<Number>] +* `ms` [<number>] +* return [<number>] Platform normalizes timeout. ### PIPE -* [<String>] +* [<string>] Path to the test socket. ### PORT -* [<Number>] +* [<number>] A port number for tests to use if one is needed. ### printSkipMessage(msg) -* `msg` [<String>] +* `msg` [<string>] Logs '1..0 # Skipped: ' + `msg` @@ -349,12 +349,12 @@ Restore the original `process.stdout.write`. Used to restore `stdout` to its original state after calling [`common.hijackStdOut()`][]. ### rootDir -* [<String>] +* [<string>] Path to the 'root' directory. either `/` or `c:\\` (windows) ### skip(msg) -* `msg` [<String>] +* `msg` [<string>] Logs '1..0 # Skipped: ' + `msg` and exits with exit code `0`. @@ -427,8 +427,8 @@ The `DNS` module provides utilities related to the `dns` built-in module. ### errorLookupMock(code, syscall) -* `code` [<String>] Defaults to `dns.mockedErrorCode`. -* `syscall` [<String>] Defaults to `dns.mockedSysCall`. +* `code` [<string>] Defaults to `dns.mockedErrorCode`. +* `syscall` [<string>] Defaults to `dns.mockedSysCall`. * return [<Function>] A mock for the `lookup` option of `net.connect()` that would result in an error @@ -446,7 +446,7 @@ The default `syscall` of errors generated by `errorLookupMock`. ### readDomainFromPacket(buffer, offset) * `buffer` [<Buffer>] -* `offset` [<Number>] +* `offset` [<number>] * return [<Object>] Reads the domain string from a packet and returns an object containing the @@ -462,14 +462,14 @@ the packet depending on the type of packet. ### writeIPv6(ip) -* `ip` [<String>] +* `ip` [<string>] * return [<Buffer>] Reads an IPv6 String and returns a Buffer containing the parts. ### writeDomainName(domain) -* `domain` [<String>] +* `domain` [<string>] * return [<Buffer>] Reads a Domain String and returns a Buffer containing the domain. @@ -497,26 +497,26 @@ files in the `test/fixtures` directory. ### fixtures.fixturesDir -* [<String>] +* [<string>] The absolute path to the `test/fixtures/` directory. ### fixtures.path(...args) -* `...args` [<String>] +* `...args` [<string>] Returns the result of `path.join(fixtures.fixturesDir, ...args)`. ### fixtures.readSync(args[, enc]) -* `args` [<String>] | [<Array>] +* `args` [<string>] | [<Array>] Returns the result of `fs.readFileSync(path.join(fixtures.fixturesDir, ...args), 'enc')`. ### fixtures.readKey(arg[, enc]) -* `arg` [<String>] +* `arg` [<string>] Returns the result of `fs.readFileSync(path.join(fixtures.fixturesDir, 'keys', arg), 'enc')`. @@ -640,26 +640,26 @@ internet-related tests. ### internet.addresses * [<Object>] - * `INET_HOST` [<String>] A generic host that has registered common + * `INET_HOST` [<string>] A generic host that has registered common DNS records, supports both IPv4 and IPv6, and provides basic HTTP/HTTPS services - * `INET4_HOST` [<String>] A host that provides IPv4 services - * `INET6_HOST` [<String>] A host that provides IPv6 services - * `INET4_IP` [<String>] An accessible IPv4 IP, defaults to the + * `INET4_HOST` [<string>] A host that provides IPv4 services + * `INET6_HOST` [<string>] A host that provides IPv6 services + * `INET4_IP` [<string>] An accessible IPv4 IP, defaults to the Google Public DNS IPv4 address - * `INET6_IP` [<String>] An accessible IPv6 IP, defaults to the + * `INET6_IP` [<string>] An accessible IPv6 IP, defaults to the Google Public DNS IPv6 address - * `INVALID_HOST` [<String>] An invalid host that cannot be resolved - * `MX_HOST` [<String>] A host with MX records registered - * `SRV_HOST` [<String>] A host with SRV records registered - * `PTR_HOST` [<String>] A host with PTR records registered - * `NAPTR_HOST` [<String>] A host with NAPTR records registered - * `SOA_HOST` [<String>] A host with SOA records registered - * `CNAME_HOST` [<String>] A host with CNAME records registered - * `NS_HOST` [<String>] A host with NS records registered - * `TXT_HOST` [<String>] A host with TXT records registered - * `DNS4_SERVER` [<String>] An accessible IPv4 DNS server - * `DNS6_SERVER` [<String>] An accessible IPv6 DNS server + * `INVALID_HOST` [<string>] An invalid host that cannot be resolved + * `MX_HOST` [<string>] A host with MX records registered + * `SRV_HOST` [<string>] A host with SRV records registered + * `PTR_HOST` [<string>] A host with PTR records registered + * `NAPTR_HOST` [<string>] A host with NAPTR records registered + * `SOA_HOST` [<string>] A host with SOA records registered + * `CNAME_HOST` [<string>] A host with CNAME records registered + * `NS_HOST` [<string>] A host with NS records registered + * `TXT_HOST` [<string>] A host with TXT records registered + * `DNS4_SERVER` [<string>] An accessible IPv4 DNS server + * `DNS6_SERVER` [<string>] An accessible IPv6 DNS server A set of addresses for internet-related tests. All properties are configurable via `NODE_TEST_*` environment variables. For example, to configure @@ -671,7 +671,7 @@ variable `NODE_TEST_INET_HOST` to a specified host. The `tmpdir` module supports the use of a temporary directory for testing. ### path -* [<String>] +* [<string>] The realpath of the testing temporary directory. @@ -697,13 +697,13 @@ implementation with tests from [<Array>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array [<ArrayBufferView[]>]: https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView -[<Boolean>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type [<Buffer>]: https://nodejs.org/api/buffer.html#buffer_class_buffer [<Function>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function -[<Number>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type [<Object>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object [<RegExp>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp -[<String>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type +[<boolean>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type +[<number>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type +[<string>]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type [`common.hijackStdErr()`]: #hijackstderrlistener [`common.hijackStdOut()`]: #hijackstdoutlistener [internationalization]: https://github.com/nodejs/node/wiki/Intl From 2d76379e30ea1f31593f282ab7fb5368eddd2367 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 20 Feb 2018 05:21:05 +0100 Subject: [PATCH 05/47] src: fix deprecation warning in node_perf.cc Currently the following deprecation warning is produced when compiling node_perf.cc: ./src/node_perf.cc:91:11: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations] node::MakeCallback(env->isolate(), ^ ../src/node.h:172:50: note: 'MakeCallback' has been explicitly marked deprecated here NODE_EXTERN v8::Local MakeCallback( ^ 1 warning generated. This commit adds an async_context to the call and checks the maybe result. PR-URL: https://github.com/nodejs/node/pull/18877 Reviewed-By: Ali Ijaz Sheikh --- src/node_perf.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/node_perf.cc b/src/node_perf.cc index 48b8d02b79f..8ee805a8382 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -91,7 +91,8 @@ void PerformanceEntry::Notify(Environment* env, node::MakeCallback(env->isolate(), env->process_object(), env->performance_entry_callback(), - 1, &object); + 1, &object, + node::async_context{0, 0}).ToLocalChecked(); } } From 53a5d87becb664c183d63a5c028641bc248f0771 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 20 Feb 2018 05:41:28 +0100 Subject: [PATCH 06/47] test: fix deprecation warning in binding.cc Currently, the make-callback-domain-warning addon generates the following warning: ../binding.cc:22:9: warning: 'MakeCallback' is deprecated: Use MakeCallback(..., async_context) [-Wdeprecated-declarations] node::MakeCallback(isolate, recv, method, 0, nullptr); ^ ../../../../src/node.h:172:50: note: 'MakeCallback' has been explicitly marked deprecated here NODE_EXTERN v8::Local MakeCallback( ^ 1 warning generated. This commit fixes this warning. PR-URL: https://github.com/nodejs/node/pull/18877 Reviewed-By: Ali Ijaz Sheikh --- test/addons/make-callback-domain-warning/binding.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/addons/make-callback-domain-warning/binding.cc b/test/addons/make-callback-domain-warning/binding.cc index c42166c7455..d02c8f51766 100644 --- a/test/addons/make-callback-domain-warning/binding.cc +++ b/test/addons/make-callback-domain-warning/binding.cc @@ -19,7 +19,8 @@ void MakeCallback(const FunctionCallbackInfo& args) { Local recv = args[0].As(); Local method = args[1].As(); - node::MakeCallback(isolate, recv, method, 0, nullptr); + node::MakeCallback(isolate, recv, method, 0, nullptr, + node::async_context{0, 0}); } void Initialize(Local exports) { From b5444301f5207187c4e8f104868f66980e7fe430 Mon Sep 17 00:00:00 2001 From: Roman Reiss Date: Wed, 21 Feb 2018 19:38:36 +0100 Subject: [PATCH 07/47] doc: remove CII badge in README PR-URL: https://github.com/nodejs/node/pull/18908 Reviewed-By: Rod Vagg Reviewed-By: Rich Trott Reviewed-By: Jeremiah Senkpiel Reviewed-By: Daijiro Wachi Reviewed-By: Colin Ihrig Reviewed-By: Gus Caplan Reviewed-By: Ruben Bridgewater --- README.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/README.md b/README.md index 687f0fb4723..9dda47e821f 100644 --- a/README.md +++ b/README.md @@ -3,9 +3,6 @@ Node.js

-

- -

Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. For more information on using Node.js, see the From 2990429b16f32c216d357a5cbf3f81d43aa8abaf Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Wed, 21 Feb 2018 08:10:07 +0100 Subject: [PATCH 08/47] src: remove unused using declarations async_wrap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/18893 Reviewed-By: Michaël Zasso Reviewed-By: Minwoo Jung Reviewed-By: Yuta Hiroto Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Gibson Fahnestock --- src/async_wrap.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/async_wrap.cc b/src/async_wrap.cc index 57f61d94923..a7eed82958c 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -27,9 +27,7 @@ #include "v8.h" #include "v8-profiler.h" -using v8::Array; using v8::Context; -using v8::Float64Array; using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; @@ -47,7 +45,6 @@ using v8::PromiseHookType; using v8::PropertyCallbackInfo; using v8::RetainedObjectInfo; using v8::String; -using v8::TryCatch; using v8::Undefined; using v8::Value; From 45982de4184e66bb53577b9c07383189f3d83dde Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Sat, 10 Feb 2018 14:52:18 +0100 Subject: [PATCH 09/47] cluster: fix inspector port assignment Make sure that inspector ports in cluster are inside the valid range: `[1024, 65535]`. Fixes flaky `test-inspector-port-zero-cluster`. PR-URL: https://github.com/nodejs/node/pull/18696 Fixes: https://github.com/nodejs/node/issues/18303 Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater --- lib/internal/cluster/master.js | 3 +++ test/sequential/test-inspector-port-cluster.js | 10 ++++++++++ test/sequential/test-inspector-port-zero-cluster.js | 10 ++++------ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/internal/cluster/master.js b/lib/internal/cluster/master.js index 570cf7bc6f9..3c6a398f117 100644 --- a/lib/internal/cluster/master.js +++ b/lib/internal/cluster/master.js @@ -14,6 +14,7 @@ const intercom = new EventEmitter(); const SCHED_NONE = 1; const SCHED_RR = 2; const { isLegalPort } = require('internal/net'); +const [ minPort, maxPort ] = [ 1024, 65535 ]; module.exports = cluster; @@ -119,6 +120,8 @@ function createWorkerProcess(id, env) { } } else { inspectPort = process.debugPort + debugPortOffset; + if (inspectPort > maxPort) + inspectPort = inspectPort - maxPort + minPort - 1; debugPortOffset++; } diff --git a/test/sequential/test-inspector-port-cluster.js b/test/sequential/test-inspector-port-cluster.js index 84ec408ebfb..87469aa7ff7 100644 --- a/test/sequential/test-inspector-port-cluster.js +++ b/test/sequential/test-inspector-port-cluster.js @@ -24,6 +24,16 @@ function testRunnerMain() { workers: [{ expectedPort: 9230 }] }); + spawnMaster({ + execArgv: ['--inspect=65534'], + workers: [ + { expectedPort: 65535 }, + { expectedPort: 1024 }, + { expectedPort: 1025 }, + { expectedPort: 1026 } + ] + }); + let port = debuggerPort + offset++ * 5; spawnMaster({ diff --git a/test/sequential/test-inspector-port-zero-cluster.js b/test/sequential/test-inspector-port-zero-cluster.js index f64e05f314c..e522056571d 100644 --- a/test/sequential/test-inspector-port-zero-cluster.js +++ b/test/sequential/test-inspector-port-zero-cluster.js @@ -30,16 +30,14 @@ function serialFork() { if (cluster.isMaster) { Promise.all([serialFork(), serialFork(), serialFork()]) .then(common.mustCall((ports) => { - ports.push(process.debugPort); - ports.sort(); + ports.splice(0, 0, process.debugPort); // 4 = [master, worker1, worker2, worker3].length() assert.strictEqual(ports.length, 4); assert(ports.every((port) => port > 0)); assert(ports.every((port) => port < 65536)); - // Ports should be consecutive. - assert.strictEqual(ports[0] + 1, ports[1]); - assert.strictEqual(ports[1] + 1, ports[2]); - assert.strictEqual(ports[2] + 1, ports[3]); + assert.strictEqual(ports[0] === 65535 ? 1024 : ports[0] + 1, ports[1]); + assert.strictEqual(ports[1] === 65535 ? 1024 : ports[1] + 1, ports[2]); + assert.strictEqual(ports[2] === 65535 ? 1024 : ports[2] + 1, ports[3]); })) .catch( (err) => { From 281d00eebdc53e4a018cf4876f04eaf75538afd2 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 6 Feb 2018 23:00:15 +0100 Subject: [PATCH 10/47] net: inline and simplify onSocketEnd PR-URL: https://github.com/nodejs/node/pull/18607 Reviewed-By: Luigi Pinca Reviewed-By: Matteo Collina Reviewed-By: James M Snell --- lib/net.js | 41 ++++++++---------------------- test/parallel/test-http-connect.js | 3 ++- 2 files changed, 13 insertions(+), 31 deletions(-) diff --git a/lib/net.js b/lib/net.js index edf8a6c0bc5..7095a5190a1 100644 --- a/lib/net.js +++ b/lib/net.js @@ -256,7 +256,7 @@ function Socket(options) { } // shut down the socket when we're finished with it. - this.on('_socketEnd', onSocketEnd); + this.on('end', onReadableStreamEnd); initSocketHandle(this); @@ -360,32 +360,6 @@ function afterShutdown(status, handle) { } } -// the EOF has been received, and no more bytes are coming. -// if the writable side has ended already, then clean everything -// up. -function onSocketEnd() { - // XXX Should not have to do as much in this function. - // ended should already be true, since this is called *after* - // the EOF errno and onread has eof'ed - debug('onSocketEnd', this._readableState); - this._readableState.ended = true; - if (this._readableState.endEmitted) { - this.readable = false; - maybeDestroy(this); - } else { - this.once('end', function end() { - this.readable = false; - maybeDestroy(this); - }); - this.read(0); - } - - if (!this.allowHalfOpen) { - this.write = writeAfterFIN; - this.destroySoon(); - } -} - // Provide a better error message when we call end() as a result // of the other side sending a FIN. The standard 'write after end' // is overly vague, and makes it seem like the user's code is to blame. @@ -537,6 +511,12 @@ Socket.prototype.end = function(data, encoding, callback) { }; +// Called when the 'end' event is emitted. +function onReadableStreamEnd() { + maybeDestroy(this); +} + + // Call whenever we set writable=false or readable=false function maybeDestroy(socket) { if (!socket.readable && @@ -651,10 +631,11 @@ function onread(nread, buffer) { // Do it before `maybeDestroy` for correct order of events: // `end` -> `close` self.push(null); + self.read(0); - if (self.readableLength === 0) { - self.readable = false; - maybeDestroy(self); + if (!self.allowHalfOpen) { + self.write = writeAfterFIN; + self.destroySoon(); } // internal end event so that we know that the actual socket diff --git a/test/parallel/test-http-connect.js b/test/parallel/test-http-connect.js index b019c61573e..06f855db9a0 100644 --- a/test/parallel/test-http-connect.js +++ b/test/parallel/test-http-connect.js @@ -65,7 +65,8 @@ server.listen(0, common.mustCall(() => { // the stream.Duplex onend listener // allow 0 here, so that i can run the same test on streams1 impl - assert(socket.listeners('end').length <= 1); + assert(socket.listenerCount('end') <= 2, + `Found ${socket.listenerCount('end')} end listeners`); assert.strictEqual(socket.listeners('free').length, 0); assert.strictEqual(socket.listeners('close').length, 0); From 7876aeb0fe01acf007401cfedf12709f834c927b Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Thu, 14 Dec 2017 13:14:06 -0800 Subject: [PATCH 11/47] crypto: add cert.fingerprint256 as SHA256 fingerprint PR-URL: https://github.com/nodejs/node/pull/17690 Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Ruben Bridgewater --- src/env.h | 1 + src/node_crypto.cc | 47 ++++++++++++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/src/env.h b/src/env.h index dab9aec9970..a4454d55c1c 100644 --- a/src/env.h +++ b/src/env.h @@ -170,6 +170,7 @@ struct PackageConfig { V(fd_string, "fd") \ V(file_string, "file") \ V(fingerprint_string, "fingerprint") \ + V(fingerprint256_string, "fingerprint256") \ V(flags_string, "flags") \ V(get_data_clone_error_string, "_getDataCloneError") \ V(get_shared_array_buffer_id_string, "_getSharedArrayBufferId") \ diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 211b142f383..202de9cf675 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1790,6 +1790,25 @@ static bool SafeX509ExtPrint(BIO* out, X509_EXTENSION* ext) { } +static void AddFingerprintDigest(const unsigned char* md, + unsigned int md_size, + char (*fingerprint)[3 * EVP_MAX_MD_SIZE + 1]) { + unsigned int i; + const char hex[] = "0123456789ABCDEF"; + + for (i = 0; i < md_size; i++) { + (*fingerprint)[3*i] = hex[(md[i] & 0xf0) >> 4]; + (*fingerprint)[(3*i)+1] = hex[(md[i] & 0x0f)]; + (*fingerprint)[(3*i)+2] = ':'; + } + + if (md_size > 0) { + (*fingerprint)[(3*(md_size-1))+2] = '\0'; + } else { + (*fingerprint)[0] = '\0'; + } +} + static Local X509ToObject(Environment* env, X509* cert) { EscapableHandleScope scope(env->isolate()); Local context = env->context(); @@ -1906,26 +1925,18 @@ static Local X509ToObject(Environment* env, X509* cert) { mem->length)).FromJust(); BIO_free_all(bio); - unsigned int md_size, i; unsigned char md[EVP_MAX_MD_SIZE]; + unsigned int md_size; + char fingerprint[EVP_MAX_MD_SIZE * 3 + 1]; if (X509_digest(cert, EVP_sha1(), md, &md_size)) { - const char hex[] = "0123456789ABCDEF"; - char fingerprint[EVP_MAX_MD_SIZE * 3]; - - for (i = 0; i < md_size; i++) { - fingerprint[3*i] = hex[(md[i] & 0xf0) >> 4]; - fingerprint[(3*i)+1] = hex[(md[i] & 0x0f)]; - fingerprint[(3*i)+2] = ':'; - } - - if (md_size > 0) { - fingerprint[(3*(md_size-1))+2] = '\0'; - } else { - fingerprint[0] = '\0'; - } - - info->Set(context, env->fingerprint_string(), - OneByteString(env->isolate(), fingerprint)).FromJust(); + AddFingerprintDigest(md, md_size, &fingerprint); + info->Set(context, env->fingerprint_string(), + OneByteString(env->isolate(), fingerprint)).FromJust(); + } + if (X509_digest(cert, EVP_sha256(), md, &md_size)) { + AddFingerprintDigest(md, md_size, &fingerprint); + info->Set(context, env->fingerprint256_string(), + OneByteString(env->isolate(), fingerprint)).FromJust(); } STACK_OF(ASN1_OBJECT)* eku = static_cast( From 5a6beb774128a890830d3dc7b742929dc539418e Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Tue, 6 Feb 2018 21:34:08 -0800 Subject: [PATCH 12/47] crypto: add cert.pubkey containing the raw pubkey of certificate PR-URL: https://github.com/nodejs/node/pull/17690 Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Ruben Bridgewater --- src/env.h | 1 + src/node_crypto.cc | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/env.h b/src/env.h index a4454d55c1c..4df4cb13b82 100644 --- a/src/env.h +++ b/src/env.h @@ -242,6 +242,7 @@ struct PackageConfig { V(priority_string, "priority") \ V(produce_cached_data_string, "produceCachedData") \ V(promise_string, "promise") \ + V(pubkey_string, "pubkey") \ V(raw_string, "raw") \ V(read_host_object_string, "_readHostObject") \ V(readable_string, "readable") \ diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 202de9cf675..a21e37408de 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1898,6 +1898,14 @@ static Local X509ToObject(Environment* env, X509* cert) { String::kNormalString, mem->length)).FromJust(); USE(BIO_reset(bio)); + + int size = i2d_RSA_PUBKEY(rsa, nullptr); + CHECK_GE(size, 0); + Local pubbuff = Buffer::New(env, size).ToLocalChecked(); + unsigned char* pubserialized = + reinterpret_cast(Buffer::Data(pubbuff)); + i2d_RSA_PUBKEY(rsa, &pubserialized); + info->Set(env->pubkey_string(), pubbuff); } if (pkey != nullptr) { From 853f0bdf1908f754a0e7a7486339e79578c2c68b Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Thu, 14 Dec 2017 15:45:44 -0800 Subject: [PATCH 13/47] crypto: provide full cert details to checkServerIdentity PR-URL: https://github.com/nodejs/node/pull/17690 Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Ruben Bridgewater --- lib/_tls_wrap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index fcd447bb590..b3c48b950c6 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -1055,7 +1055,7 @@ function onConnectSecure() { options.host || (options.socket && options.socket._host) || 'localhost'; - const cert = this.getPeerCertificate(); + const cert = this.getPeerCertificate(true); verifyError = options.checkServerIdentity(hostname, cert); } From 6aab9e1eed68b10e027b87795285b34eafdcf229 Mon Sep 17 00:00:00 2001 From: Hannes Magnusson Date: Wed, 14 Feb 2018 09:35:10 -0800 Subject: [PATCH 14/47] crypto: add docs & tests for cert.pubkey & cert.fingerprint256 Include example on how to pin certificate and/or public key PR-URL: https://github.com/nodejs/node/pull/17690 Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Ruben Bridgewater --- doc/api/https.md | 92 ++++++++++++++++++++++ doc/api/tls.md | 6 +- test/parallel/test-tls-peer-certificate.js | 28 ++++++- 3 files changed, 124 insertions(+), 2 deletions(-) diff --git a/doc/api/https.md b/doc/api/https.md index 58e62ccced4..da4dbb22abe 100644 --- a/doc/api/https.md +++ b/doc/api/https.md @@ -251,6 +251,98 @@ const req = https.request(options, (res) => { }); ``` +Example pinning on certificate fingerprint, or the public key (similar to `pin-sha256`): + +```js +const tls = require('tls'); +const https = require('https'); +const crypto = require('crypto'); + +function sha256(s) { + return crypto.createHash('sha256').update(s).digest('base64'); +} +const options = { + hostname: 'github.com', + port: 443, + path: '/', + method: 'GET', + checkServerIdentity: function(host, cert) { + // Make sure the certificate is issued to the host we are connected to + const err = tls.checkServerIdentity(host, cert); + if (err) { + return err; + } + + // Pin the public key, similar to HPKP pin-sha25 pinning + const pubkey256 = 'pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU='; + if (sha256(cert.pubkey) !== pubkey256) { + const msg = 'Certificate verification error: ' + + `The public key of '${cert.subject.CN}' ` + + 'does not match our pinned fingerprint'; + return new Error(msg); + } + + // Pin the exact certificate, rather then the pub key + const cert256 = '25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:' + + 'D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16'; + if (cert.fingerprint256 !== cert256) { + const msg = 'Certificate verification error: ' + + `The certificate of '${cert.subject.CN}' ` + + 'does not match our pinned fingerprint'; + return new Error(msg); + } + + // This loop is informational only. + // Print the certificate and public key fingerprints of all certs in the + // chain. Its common to pin the public key of the issuer on the public + // internet, while pinning the public key of the service in sensitive + // environments. + do { + console.log('Subject Common Name:', cert.subject.CN); + console.log(' Certificate SHA256 fingerprint:', cert.fingerprint256); + + hash = crypto.createHash('sha256'); + console.log(' Public key ping-sha256:', sha256(cert.pubkey)); + + lastprint256 = cert.fingerprint256; + cert = cert.issuerCertificate; + } while (cert.fingerprint256 !== lastprint256); + + }, +}; + +options.agent = new https.Agent(options); +const req = https.request(options, (res) => { + console.log('All OK. Server matched our pinned cert or public key'); + console.log('statusCode:', res.statusCode); + // Print the HPKP values + console.log('headers:', res.headers['public-key-pins']); + + res.on('data', (d) => {}); +}); + +req.on('error', (e) => { + console.error(e.message); +}); +req.end(); + +``` + Outputs for example: +```text +Subject Common Name: github.com + Certificate SHA256 fingerprint: 25:FE:39:32:D9:63:8C:8A:FC:A1:9A:29:87:D8:3E:4C:1D:98:DB:71:E4:1A:48:03:98:EA:22:6A:BD:8B:93:16 + Public key ping-sha256: pL1+qb9HTMRZJmuC/bB/ZI9d302BYrrqiVuRyW+DGrU= +Subject Common Name: DigiCert SHA2 Extended Validation Server CA + Certificate SHA256 fingerprint: 40:3E:06:2A:26:53:05:91:13:28:5B:AF:80:A0:D4:AE:42:2C:84:8C:9F:78:FA:D0:1F:C9:4B:C5:B8:7F:EF:1A + Public key ping-sha256: RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho= +Subject Common Name: DigiCert High Assurance EV Root CA + Certificate SHA256 fingerprint: 74:31:E5:F4:C3:C1:CE:46:90:77:4F:0B:61:E0:54:40:88:3B:A9:A0:1E:D0:0B:A6:AB:D7:80:6E:D3:B1:18:CF + Public key ping-sha256: WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18= +All OK. Server matched our pinned cert or public key +statusCode: 200 +headers: max-age=0; pin-sha256="WoiWRyIOVNa9ihaBciRSC7XHjliYS9VwUGOIud4PB18="; pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho="; pin-sha256="k2v657xBsOVe1PQRwOsHsw3bsGT2VzIqz5K+59sNQws="; pin-sha256="K87oWBWM9UZfyddvDfoxL+8lpNyoUB2ptGtn0fv6G2Q="; pin-sha256="IQBnNBEiFuhj+8x6X8XLgh01V9Ic5/V3IRQLNFFc7v4="; pin-sha256="iie1VXtL7HzAMF+/PVPR9xzT80kQxdZeJ+zduCB3uj0="; pin-sha256="LvRiGEjRqfzurezaWuj8Wie2gyHMrW5Q06LspMnox7A="; includeSubDomains +``` + [`Agent`]: #https_class_https_agent [`URL`]: url.html#url_the_whatwg_url_api [`http.Agent`]: http.html#http_class_http_agent diff --git a/doc/api/tls.md b/doc/api/tls.md index 161ec5d9633..5cdab4cbd35 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -618,9 +618,11 @@ For example: issuerCertificate: { ... another certificate, possibly with a .issuerCertificate ... }, raw: < RAW DER buffer >, + pubkey: < RAW DER buffer >, valid_from: 'Nov 11 09:52:22 2009 GMT', valid_to: 'Nov 6 09:52:22 2029 GMT', fingerprint: '2A:7A:C2:DD:E5:F9:CC:53:72:35:99:7A:02:5A:71:38:52:EC:8A:DF', + fingerprint256: '2A:7A:C2:DD:E5:F9:CC:53:72:35:99:7A:02:5A:71:38:52:EC:8A:DF:00:11:22:33:44:55:66:77:88:99:AA:BB', serialNumber: 'B9B0D332A1AA5635' } ``` @@ -786,12 +788,14 @@ similar to: 'OCSP - URI': [ 'http://ocsp.comodoca.com' ] }, modulus: 'B56CE45CB740B09A13F64AC543B712FF9EE8E4C284B542A1708A27E82A8D151CA178153E12E6DDA15BF70FFD96CB8A88618641BDFCCA03527E665B70D779C8A349A6F88FD4EF6557180BD4C98192872BCFE3AF56E863C09DDD8BC1EC58DF9D94F914F0369102B2870BECFA1348A0838C9C49BD1C20124B442477572347047506B1FCD658A80D0C44BCC16BC5C5496CFE6E4A8428EF654CD3D8972BF6E5BFAD59C93006830B5EB1056BBB38B53D1464FA6E02BFDF2FF66CD949486F0775EC43034EC2602AEFBF1703AD221DAA2A88353C3B6A688EFE8387811F645CEED7B3FE46E1F8B9F59FAD028F349B9BC14211D5830994D055EEA3D547911E07A0ADDEB8A82B9188E58720D95CD478EEC9AF1F17BE8141BE80906F1A339445A7EB5B285F68039B0F294598A7D1C0005FC22B5271B0752F58CCDEF8C8FD856FB7AE21C80B8A2CE983AE94046E53EDE4CB89F42502D31B5360771C01C80155918637490550E3F555E2EE75CC8C636DDE3633CFEDD62E91BF0F7688273694EEEBA20C2FC9F14A2A435517BC1D7373922463409AB603295CEB0BB53787A334C9CA3CA8B30005C5A62FC0715083462E00719A8FA3ED0A9828C3871360A73F8B04A4FC1E71302844E9BB9940B77E745C9D91F226D71AFCAD4B113AAF68D92B24DDB4A2136B55A1CD1ADF39605B63CB639038ED0F4C987689866743A68769CC55847E4A06D6E2E3F1', exponent: '0x10001', + pubkey: , valid_from: 'Aug 14 00:00:00 2017 GMT', valid_to: 'Nov 20 23:59:59 2019 GMT', fingerprint: '01:02:59:D9:C3:D2:0D:08:F7:82:4E:44:A4:B4:53:C5:E2:3A:87:4D', + fingerprint256: '69:AE:1A:6A:D4:3D:C6:C1:1B:EA:C6:23:DE:BA:2A:14:62:62:93:5C:7A:EA:06:41:9B:0B:BC:87:CE:48:4E:02', ext_key_usage: [ '1.3.6.1.5.5.7.3.1', '1.3.6.1.5.5.7.3.2' ], serialNumber: '66593D57F20CBC573E433381B5FEC280', - raw: } + raw: } ``` ## tls.connect(options[, callback]) diff --git a/test/parallel/test-tls-peer-certificate.js b/test/parallel/test-tls-peer-certificate.js index 14c3d17cd24..e5de378675f 100644 --- a/test/parallel/test-tls-peer-certificate.js +++ b/test/parallel/test-tls-peer-certificate.js @@ -20,8 +20,12 @@ // USE OR OTHER DEALINGS IN THE SOFTWARE. 'use strict'; -require('../common'); +const common = require('../common'); const fixtures = require('../common/fixtures'); +if (!common.hasCrypto) { + common.skip('missing crypto'); +} +const crypto = require('crypto'); // Verify that detailed getPeerCertificate() return value has all certs. @@ -29,6 +33,10 @@ const { assert, connect, debug, keys } = require(fixtures.path('tls-connect')); +function sha256(s) { + return crypto.createHash('sha256').update(s); +} + connect({ client: { rejectUnauthorized: false }, server: keys.agent1, @@ -49,6 +57,24 @@ connect({ peerCert.fingerprint, '8D:06:3A:B3:E5:8B:85:29:72:4F:7D:1B:54:CD:95:19:3C:EF:6F:AA' ); + assert.strictEqual( + peerCert.fingerprint256, + 'A1:DC:01:1A:EC:A3:7B:86:A8:C2:3E:26:9F:EB:EE:5C:A9:3B:BE:06' + + ':4C:A4:00:53:93:A9:66:07:A7:BC:13:32' + ); + + // SHA256 fingerprint of the public key + assert.strictEqual( + sha256(peerCert.pubkey).digest('hex'), + 'fa5152e4407bad1e7537ef5bfc3f19fa9a62ee04432fd75e109b1803704c31ba' + ); + + // HPKP / RFC7469 "pin-sha256" of the public key + assert.strictEqual( + sha256(peerCert.pubkey).digest('base64'), + '+lFS5EB7rR51N+9b/D8Z+ppi7gRDL9deEJsYA3BMMbo=' + ); + assert.deepStrictEqual(peerCert.infoAccess['OCSP - URI'], [ 'http://ocsp.nodejs.org/' ]); From ca79fc5373f2fde4a3a3cfd86c34c3848df37a1a Mon Sep 17 00:00:00 2001 From: jvelezpo Date: Fri, 16 Feb 2018 07:28:38 -0500 Subject: [PATCH 15/47] src: replace var for (let|const) in utilities module Update Utilities module to replace var for let or const PR-URL: https://github.com/nodejs/node/pull/18814 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Matheus Marchini --- lib/internal/util.js | 10 +++--- lib/util.js | 76 ++++++++++++++++++++++---------------------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/lib/internal/util.js b/lib/internal/util.js index 3de8090cfa2..630cd0ef213 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -47,7 +47,7 @@ function deprecate(fn, msg, code) { if (code !== undefined && typeof code !== 'string') throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'code', 'string'); - var warned = false; + let warned = false; function deprecated(...args) { if (!warned) { warned = true; @@ -103,7 +103,7 @@ function assertCrypto() { // Return undefined if there is no match. function normalizeEncoding(enc) { if (!enc) return 'utf8'; - var retried; + let retried; while (true) { switch (enc) { case 'utf8': @@ -152,7 +152,7 @@ function filterDuplicateStrings(items, low) { } function cachedResult(fn) { - var result; + let result; return () => { if (result === undefined) result = fn(); @@ -207,7 +207,7 @@ function convertToValidSignal(signal) { function getConstructorOf(obj) { while (obj) { - var descriptor = Object.getOwnPropertyDescriptor(obj, 'constructor'); + const descriptor = Object.getOwnPropertyDescriptor(obj, 'constructor'); if (descriptor !== undefined && typeof descriptor.value === 'function' && descriptor.value.name !== '') { @@ -323,7 +323,7 @@ promisify.custom = kCustomPromisifiedSymbol; // The build-in Array#join is slower in v8 6.0 function join(output, separator) { - var str = ''; + let str = ''; if (output.length !== 0) { for (var i = 0; i < output.length - 1; i++) { // It is faster not to use a template string here diff --git a/lib/util.js b/lib/util.js index 93729991cd5..a019036ede6 100644 --- a/lib/util.js +++ b/lib/util.js @@ -79,7 +79,7 @@ const regExpToString = RegExp.prototype.toString; const dateToISOString = Date.prototype.toISOString; const errorToString = Error.prototype.toString; -var CIRCULAR_ERROR_MESSAGE; +let CIRCULAR_ERROR_MESSAGE; /* eslint-disable */ const strEscapeSequencesRegExp = /[\x00-\x1f\x27\x5c]/; @@ -119,8 +119,8 @@ function strEscape(str) { return `'${str}'`; if (str.length > 100) return `'${str.replace(strEscapeSequencesReplacer, escapeFn)}'`; - var result = ''; - var last = 0; + let result = ''; + let last = 0; for (var i = 0; i < str.length; i++) { const point = str.charCodeAt(i); if (point === 39 || point === 92 || point < 32) { @@ -159,10 +159,10 @@ function tryStringify(arg) { } function format(f) { - var i, tempStr; + let i, tempStr; if (typeof f !== 'string') { if (arguments.length === 0) return ''; - var res = ''; + let res = ''; for (i = 0; i < arguments.length - 1; i++) { res += inspect(arguments[i]); res += ' '; @@ -173,9 +173,9 @@ function format(f) { if (arguments.length === 1) return f; - var str = ''; - var a = 1; - var lastPos = 0; + let str = ''; + let a = 1; + let lastPos = 0; for (i = 0; i < f.length - 1; i++) { if (f.charCodeAt(i) === 37) { // '%' const nextChar = f.charCodeAt(++i); @@ -250,9 +250,9 @@ function debuglog(set) { set = set.toUpperCase(); if (!debugs[set]) { if (debugEnvRegex.test(set)) { - var pid = process.pid; + const pid = process.pid; debugs[set] = function() { - var msg = exports.format.apply(exports, arguments); + const msg = exports.format.apply(exports, arguments); console.error('%s %d: %s', set, pid, msg); }; } else { @@ -426,8 +426,8 @@ function formatValue(ctx, value, recurseTimes, ln) { } } - var keys; - var symbols = Object.getOwnPropertySymbols(value); + let keys; + let symbols = Object.getOwnPropertySymbols(value); // Look up the keys of the object. if (ctx.showHidden) { @@ -441,7 +441,7 @@ function formatValue(ctx, value, recurseTimes, ln) { const keyLength = keys.length + symbols.length; const { constructor, tag } = getIdentificationOf(value); - var prefix = ''; + let prefix = ''; if (constructor && tag && constructor !== tag) prefix = `${constructor} [${tag}] `; else if (constructor) @@ -449,11 +449,11 @@ function formatValue(ctx, value, recurseTimes, ln) { else if (tag) prefix = `[${tag}] `; - var base = ''; - var formatter = formatObject; - var braces; - var noIterator = true; - var raw; + let base = ''; + let formatter = formatObject; + let braces; + let noIterator = true; + let raw; // Iterators and the rest are split to reduce checks if (value[Symbol.iterator]) { @@ -623,7 +623,7 @@ function formatPrimitive(fn, value, ctx) { // eslint-disable-next-line max-len const averageLineLength = Math.ceil(value.length / Math.ceil(value.length / minLineLength)); const divisor = Math.max(averageLineLength, MIN_LINE_LENGTH); - var res = ''; + let res = ''; if (readableRegExps[divisor] === undefined) { // Build a new RegExp that naturally breaks text into multiple lines. // @@ -678,8 +678,8 @@ function formatObject(ctx, value, recurseTimes, keys) { function formatSpecialArray(ctx, value, recurseTimes, keys, maxLength, valLen) { const output = []; const keyLen = keys.length; - var visibleLength = 0; - var i = 0; + let visibleLength = 0; + let i = 0; if (keyLen !== 0 && numberRegExp.test(keys[0])) { for (const key of keys) { if (visibleLength === maxLength) @@ -728,7 +728,7 @@ function formatSpecialArray(ctx, value, recurseTimes, keys, maxLength, valLen) { } else if (keys[keyLen - 1] !== `${valLen - 1}`) { const extra = []; // Only handle special keys - var key; + let key; for (i = keys.length - 1; i >= 0; i--) { key = keys[i]; if (numberRegExp.test(key) && +key < 2 ** 32 - 1) @@ -792,7 +792,7 @@ function formatTypedArray(ctx, value, recurseTimes, keys) { function formatSet(ctx, value, recurseTimes, keys) { const output = new Array(value.size + keys.length + (ctx.showHidden ? 1 : 0)); - var i = 0; + let i = 0; for (const v of value) output[i++] = formatValue(ctx, v, recurseTimes); // With `showHidden`, `length` will display as a hidden property for @@ -808,7 +808,7 @@ function formatSet(ctx, value, recurseTimes, keys) { function formatMap(ctx, value, recurseTimes, keys) { const output = new Array(value.size + keys.length + (ctx.showHidden ? 1 : 0)); - var i = 0; + let i = 0; for (const [k, v] of value) output[i++] = `${formatValue(ctx, k, recurseTimes)} => ` + formatValue(ctx, v, recurseTimes); @@ -823,9 +823,9 @@ function formatMap(ctx, value, recurseTimes, keys) { function formatCollectionIterator(preview, ctx, value, recurseTimes, visibleKeys, keys) { - var nextRecurseTimes = recurseTimes === null ? null : recurseTimes - 1; - var vals = preview(value, 100); - var output = []; + const nextRecurseTimes = recurseTimes === null ? null : recurseTimes - 1; + const vals = preview(value, 100); + const output = []; for (const o of vals) { output.push(formatValue(ctx, o, nextRecurseTimes)); } @@ -843,7 +843,7 @@ function formatSetIterator(ctx, value, recurseTimes, visibleKeys, keys) { } function formatPromise(ctx, value, recurseTimes, keys) { - var output; + let output; const [state, result] = getPromiseDetails(value); if (state === kPending) { output = ['']; @@ -858,7 +858,7 @@ function formatPromise(ctx, value, recurseTimes, keys) { } function formatProperty(ctx, value, recurseTimes, key, array) { - var name, str; + let name, str; const desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key], enumerable: true }; if (desc.value !== undefined) { @@ -895,10 +895,10 @@ function formatProperty(ctx, value, recurseTimes, key, array) { function reduceToSingleString(ctx, output, base, braces, addLn) { const breakLength = ctx.breakLength; - var i = 0; + let i = 0; if (ctx.compact === false) { const indentation = ' '.repeat(ctx.indentationLvl); - var res = `${base ? `${base} ` : ''}${braces[0]}\n${indentation} `; + let res = `${base ? `${base} ` : ''}${braces[0]}\n${indentation} `; for (; i < output.length - 1; i++) { res += `${output[i]},\n${indentation} `; } @@ -906,7 +906,7 @@ function reduceToSingleString(ctx, output, base, braces, addLn) { return res; } if (output.length * 2 <= breakLength) { - var length = 0; + let length = 0; for (; i < output.length && length <= breakLength; i++) { if (ctx.colors) { length += removeColors(output[i]).length + 1; @@ -979,10 +979,10 @@ const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', // 26 Feb 16:19:34 function timestamp() { - var d = new Date(); - var time = [pad(d.getHours()), - pad(d.getMinutes()), - pad(d.getSeconds())].join(':'); + const d = new Date(); + const time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); return [d.getDate(), months[d.getMonth()], time].join(' '); } @@ -1026,8 +1026,8 @@ function _extend(target, source) { // Don't do anything if source isn't an object if (source === null || typeof source !== 'object') return target; - var keys = Object.keys(source); - var i = keys.length; + const keys = Object.keys(source); + let i = keys.length; while (i--) { target[keys[i]] = source[keys[i]]; } From 3cb3618973bcf7817b55eb4fd96cc5fe7284cbd9 Mon Sep 17 00:00:00 2001 From: "Timothy O. Peters" Date: Mon, 12 Feb 2018 19:58:15 +0100 Subject: [PATCH 16/47] vm: consolidate validation PR-URL: https://github.com/nodejs/node/pull/18816 Reviewed-By: Ruben Bridgewater Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: Luigi Pinca --- lib/vm.js | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/lib/vm.js b/lib/vm.js index c9bb44f0573..78a2de16d38 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -79,22 +79,23 @@ Script.prototype.runInNewContext = function(sandbox, options) { return this.runInContext(context, options); }; +function validateString(prop, propName) { + if (prop !== undefined && typeof prop !== 'string') + throw new errors.TypeError('ERR_INVALID_ARG_TYPE', propName, + 'string', prop); +} + function getContextOptions(options) { - const contextOptions = options ? { - name: options.contextName, - origin: options.contextOrigin - } : {}; - if (contextOptions.name !== undefined && - typeof contextOptions.name !== 'string') { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'options.contextName', - 'string', contextOptions.name); - } - if (contextOptions.origin !== undefined && - typeof contextOptions.origin !== 'string') { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'options.contextOrigin', - 'string', contextOptions.origin); + if (options) { + const contextOptions = { + name: options.contextName, + origin: options.contextOrigin + }; + validateString(contextOptions.name, 'options.contextName'); + validateString(contextOptions.origin, 'options.contextOrigin'); + return contextOptions; } - return contextOptions; + return {}; } let defaultContextNameIndex = 1; @@ -120,10 +121,7 @@ function createContext(sandbox, options) { throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'options.name', 'string', options.name); } - if (options.origin !== undefined && typeof options.origin !== 'string') { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'options.origin', - 'string', options.origin); - } + validateString(options.origin, 'options.origin'); } else { options = { name: `VM Context ${defaultContextNameIndex++}` From 20dae8540b4a6306d53ebd8fca88a9940c8e9c00 Mon Sep 17 00:00:00 2001 From: Trivikram <16024985+trivikr@users.noreply.github.com> Date: Sat, 17 Feb 2018 20:35:01 -0800 Subject: [PATCH 17/47] test: http2 client setNextStreamID errors PR-URL: https://github.com/nodejs/node/pull/18848 Reviewed-By: Luigi Pinca Reviewed-By: Minwoo Jung Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell --- ...est-http2-client-setNextStreamID-errors.js | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 test/parallel/test-http2-client-setNextStreamID-errors.js diff --git a/test/parallel/test-http2-client-setNextStreamID-errors.js b/test/parallel/test-http2-client-setNextStreamID-errors.js new file mode 100644 index 00000000000..0c982061b85 --- /dev/null +++ b/test/parallel/test-http2-client-setNextStreamID-errors.js @@ -0,0 +1,59 @@ +'use strict'; + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); + +const http2 = require('http2'); + +const server = http2.createServer(); +server.on('stream', (stream) => { + stream.respond(); + stream.end('ok'); +}); + +const types = { + boolean: true, + function: () => {}, + number: 1, + object: {}, + array: [], + null: null, + symbol: Symbol('test') +}; + +server.listen(0, common.mustCall(() => { + const client = http2.connect(`http://localhost:${server.address().port}`); + + client.on('connect', () => { + const outOfRangeNum = 2 ** 31; + common.expectsError( + () => client.setNextStreamID(outOfRangeNum), + { + type: RangeError, + code: 'ERR_OUT_OF_RANGE', + message: 'The value of "id" is out of range.' + + ' It must be > 0 and <= 2147483647. Received ' + outOfRangeNum + } + ); + + // should throw if something other than number is passed to setNextStreamID + Object.entries(types).forEach(([type, value]) => { + if (type === 'number') { + return; + } + + common.expectsError( + () => client.setNextStreamID(value), + { + type: TypeError, + code: 'ERR_INVALID_ARG_TYPE', + message: 'The "id" argument must be of type number' + } + ); + }); + + server.close(); + client.close(); + }); +})); From 7107c9201de10e9808e7e12a53829bf899ce19da Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sun, 18 Feb 2018 20:19:20 +0100 Subject: [PATCH 18/47] tools: fix custom eslint rule errors This fixes a few rules by making sure the input is actually ready to be checked. Otherwise those can throw TypeErrors or result in faulty error messages. PR-URL: https://github.com/nodejs/node/pull/18853 Reviewed-By: Luigi Pinca --- tools/eslint-rules/alphabetize-errors.js | 9 ++------- tools/eslint-rules/documented-errors.js | 10 ++-------- tools/eslint-rules/prefer-util-format-errors.js | 11 +++-------- tools/eslint-rules/rules-utils.js | 8 ++++++++ 4 files changed, 15 insertions(+), 23 deletions(-) diff --git a/tools/eslint-rules/alphabetize-errors.js b/tools/eslint-rules/alphabetize-errors.js index 2f604130e99..b2dcacbb866 100644 --- a/tools/eslint-rules/alphabetize-errors.js +++ b/tools/eslint-rules/alphabetize-errors.js @@ -1,5 +1,7 @@ 'use strict'; +const { isDefiningError } = require('./rules-utils.js'); + const prefix = 'Out of ASCIIbetical order - '; const opStr = ' >= '; @@ -7,13 +9,6 @@ function errorForNode(node) { return node.expression.arguments[0].value; } -function isDefiningError(node) { - return node.expression && - node.expression.type === 'CallExpression' && - node.expression.callee && - node.expression.callee.name === 'E'; -} - module.exports = { create: function(context) { let previousNode; diff --git a/tools/eslint-rules/documented-errors.js b/tools/eslint-rules/documented-errors.js index 471452d67a0..0dbabb0673a 100644 --- a/tools/eslint-rules/documented-errors.js +++ b/tools/eslint-rules/documented-errors.js @@ -2,6 +2,7 @@ const fs = require('fs'); const path = require('path'); +const { isDefiningError } = require('./rules-utils.js'); const doc = fs.readFileSync(path.resolve(__dirname, '../../doc/api/errors.md'), 'utf8'); @@ -18,18 +19,11 @@ function errorForNode(node) { return node.expression.arguments[0].value; } -function isDefiningError(node) { - return node.expression && - node.expression.type === 'CallExpression' && - node.expression.callee && - node.expression.callee.name === 'E'; -} - module.exports = { create: function(context) { return { ExpressionStatement: function(node) { - if (!isDefiningError(node)) return; + if (!isDefiningError(node) || !errorForNode(node)) return; const code = errorForNode(node); if (!isInDoc(code)) { const message = `"${code}" is not documented in doc/api/errors.md`; diff --git a/tools/eslint-rules/prefer-util-format-errors.js b/tools/eslint-rules/prefer-util-format-errors.js index f6993e62778..407b6e20dd2 100644 --- a/tools/eslint-rules/prefer-util-format-errors.js +++ b/tools/eslint-rules/prefer-util-format-errors.js @@ -1,5 +1,7 @@ 'use strict'; +const { isDefiningError } = require('./rules-utils.js'); + const errMsg = 'Please use a printf-like formatted string that util.format' + ' can consume.'; @@ -8,18 +10,11 @@ function isArrowFunctionWithTemplateLiteral(node) { node.body.type === 'TemplateLiteral'; } -function isDefiningError(node) { - return node.expression && - node.expression.type === 'CallExpression' && - node.expression.callee && - node.expression.callee.name === 'E'; -} - module.exports = { create: function(context) { return { ExpressionStatement: function(node) { - if (!isDefiningError(node)) + if (!isDefiningError(node) || node.expression.arguments.length < 2) return; const msg = node.expression.arguments[1]; diff --git a/tools/eslint-rules/rules-utils.js b/tools/eslint-rules/rules-utils.js index 88ecf658ce3..0e89a715450 100644 --- a/tools/eslint-rules/rules-utils.js +++ b/tools/eslint-rules/rules-utils.js @@ -3,6 +3,14 @@ */ 'use strict'; +module.exports.isDefiningError = function(node) { + return node.expression && + node.expression.type === 'CallExpression' && + node.expression.callee && + node.expression.callee.name === 'E' && + node.expression.arguments.length !== 0; +}; + /** * Returns true if any of the passed in modules are used in * require calls. From b1e52fe2ea99a52ace6399e9f629c965f66a2643 Mon Sep 17 00:00:00 2001 From: Sarat Addepalli Date: Thu, 15 Feb 2018 19:43:26 +0530 Subject: [PATCH 19/47] fs: support as and as+ flags in stringToFlags() PR-URL: https://github.com/nodejs/node/pull/18801 Reviewed-By: Joyee Cheung Reviewed-By: Matheus Marchini Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Ruben Bridgewater --- doc/api/fs.md | 12 ++++++++++++ lib/internal/fs.js | 4 ++++ test/parallel/test-fs-open-flags.js | 4 ++++ 3 files changed, 20 insertions(+) diff --git a/doc/api/fs.md b/doc/api/fs.md index ae559d0ecff..b0cba330c51 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -2019,11 +2019,17 @@ The file is created if it does not exist. * `'ax'` - Like `'a'` but fails if `path` exists. +* `'as'` - Open file for appending in synchronous mode. +The file is created if it does not exist. + * `'a+'` - Open file for reading and appending. The file is created if it does not exist. * `'ax+'` - Like `'a+'` but fails if `path` exists. +* `'as+'` - Open file for reading and appending in synchronous mode. +The file is created if it does not exist. + `mode` sets the file mode (permission and sticky bits), but only if the file was created. It defaults to `0o666` (readable and writable). @@ -3920,11 +3926,17 @@ The file is created if it does not exist. * `'ax'` - Like `'a'` but fails if `path` exists. +* `'as'` - Open file for appending in synchronous mode. +The file is created if it does not exist. + * `'a+'` - Open file for reading and appending. The file is created if it does not exist. * `'ax+'` - Like `'a+'` but fails if `path` exists. +* `'as+'` - Open file for reading and appending in synchronous mode. +The file is created if it does not exist. + `mode` sets the file mode (permission and sticky bits), but only if the file was created. It defaults to `0o666` (readable and writable). diff --git a/lib/internal/fs.js b/lib/internal/fs.js index 9c5c4d8ad79..04844248b0b 100644 --- a/lib/internal/fs.js +++ b/lib/internal/fs.js @@ -223,10 +223,14 @@ function stringToFlags(flags) { case 'a' : return O_APPEND | O_CREAT | O_WRONLY; case 'ax' : // Fall through. case 'xa' : return O_APPEND | O_CREAT | O_WRONLY | O_EXCL; + case 'as' : // Fall through. + case 'sa' : return O_APPEND | O_CREAT | O_WRONLY | O_SYNC; case 'a+' : return O_APPEND | O_CREAT | O_RDWR; case 'ax+': // Fall through. case 'xa+': return O_APPEND | O_CREAT | O_RDWR | O_EXCL; + case 'as+': // Fall through. + case 'sa+': return O_APPEND | O_CREAT | O_RDWR | O_SYNC; } throw new errors.TypeError('ERR_INVALID_OPT_VALUE', 'flags', flags); diff --git a/test/parallel/test-fs-open-flags.js b/test/parallel/test-fs-open-flags.js index acf5c739a93..7f70885861f 100644 --- a/test/parallel/test-fs-open-flags.js +++ b/test/parallel/test-fs-open-flags.js @@ -56,8 +56,12 @@ assert.strictEqual(stringToFlags('wx+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL); assert.strictEqual(stringToFlags('xw+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL); assert.strictEqual(stringToFlags('ax'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL); assert.strictEqual(stringToFlags('xa'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL); +assert.strictEqual(stringToFlags('as'), O_APPEND | O_CREAT | O_WRONLY | O_SYNC); +assert.strictEqual(stringToFlags('sa'), O_APPEND | O_CREAT | O_WRONLY | O_SYNC); assert.strictEqual(stringToFlags('ax+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL); assert.strictEqual(stringToFlags('xa+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL); +assert.strictEqual(stringToFlags('as+'), O_APPEND | O_CREAT | O_RDWR | O_SYNC); +assert.strictEqual(stringToFlags('sa+'), O_APPEND | O_CREAT | O_RDWR | O_SYNC); ('+ +a +r +w rw wa war raw r++ a++ w++ x +x x+ rx rx+ wxx wax xwx xxx') .split(' ') From d3955d15ff5c68acf91f35177d290ff068068a05 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Mon, 12 Feb 2018 13:03:05 +0100 Subject: [PATCH 20/47] fs: use fs.access in fs.exists Uses fs.access to implement fs.exists functionality. Fixes a issue, when a file exists but user does not have privileges to do stat on the file. Fixes: https://github.com/nodejs/node/issues/17921 PR-URL: https://github.com/nodejs/node/pull/18618 Reviewed-By: Colin Ihrig Reviewed-By: Ben Noordhuis Reviewed-By: Richard Lau Reviewed-By: Weijia Wang Reviewed-By: Joyee Cheung Reviewed-By: Ruben Bridgewater Reviewed-By: Evan Lucas Reviewed-By: James M Snell --- lib/fs.js | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index 0b17885329a..0287d81c942 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -234,14 +234,10 @@ fs.exists = function(path, callback) { } try { - path = getPathFromURL(path); - validatePath(path); + fs.access(path, fs.FS_OK, suppressedCallback); } catch (err) { return callback(false); } - var req = new FSReqWrap(); - req.oncomplete = suppressedCallback; - binding.stat(pathModule.toNamespacedPath(path), req); }; Object.defineProperty(fs.exists, internalUtil.promisify.custom, { @@ -260,13 +256,7 @@ Object.defineProperty(fs.exists, internalUtil.promisify.custom, { // TODO(joyeecheung): deprecate the never-throw-on-invalid-arguments behavior fs.existsSync = function(path) { try { - path = getPathFromURL(path); - validatePath(path); - const ctx = { path }; - binding.stat(pathModule.toNamespacedPath(path), undefined, ctx); - if (ctx.errno !== undefined) { - return false; - } + fs.accessSync(path, fs.FS_OK); return true; } catch (e) { return false; From 887a2ba92eec98ddf1e0953e742419236eff75d7 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Mon, 13 Nov 2017 16:59:11 +0100 Subject: [PATCH 21/47] build, win: vcbuild improvements Removes extra erroor messages when Python is not installed. Removes "vswhere not found" message when no VS2017 installation is found. Adds support for DEBUG_HELPER to vcbuild.bat. Fixes: https://github.com/nodejs/node/issues/16864 PR-URL: https://github.com/nodejs/node/pull/17015 Reviewed-By: Ben Noordhuis Reviewed-By: Gibson Fahnestock --- tools/msvs/find_python.cmd | 20 ++++++++++++++------ tools/msvs/vswhere_usability_wrapper.cmd | 1 - vcbuild.bat | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tools/msvs/find_python.cmd b/tools/msvs/find_python.cmd index f2a779290e8..212b5275c31 100644 --- a/tools/msvs/find_python.cmd +++ b/tools/msvs/find_python.cmd @@ -1,4 +1,5 @@ @IF NOT DEFINED DEBUG_HELPER @ECHO OFF +echo Looking for Python 2.x SETLOCAL :: If python.exe is in %Path%, just validate FOR /F "delims=" %%a IN ('where python 2^> NUL') DO ( @@ -14,18 +15,18 @@ FOR %%K IN ( "HKCU\Software", "HKLM\SOFTWARE", "HKLM\Software\Wow6432Node") DO ( :: If validate returns 0 just jump to the end IF NOT ERRORLEVEL 1 GOTO :validate ) -EXIT /B 1 +goto :no-python :: Helper subroutine to handle quotes in %1 :find-main-branch SET main_key="%~1\Python\PythonCore" -REG QUERY %main_key% /s | findstr "2." | findstr InstallPath > NUL 2> NUL +REG QUERY %main_key% /s 2> NUL | findstr "2." | findstr InstallPath > NUL 2> NUL IF NOT ERRORLEVEL 1 CALL :find-key %main_key% EXIT /B :: Query registry sub-tree for InstallPath :find-key -FOR /F "delims=" %%a IN ('REG QUERY %1 /s ^| findstr "2." ^| findstr InstallPath') DO IF NOT ERRORLEVEL 1 CALL :find-path %%a +FOR /F "delims=" %%a IN ('REG QUERY %1 /s 2> NUL ^| findstr "2." ^| findstr InstallPath') DO IF NOT ERRORLEVEL 1 CALL :find-path %%a EXIT /B :: Parse the value of %1 as the path for python.exe @@ -39,13 +40,20 @@ EXIT /B 1 :: Check if %p% holds a path to a real python2 executable :validate -IF NOT EXIST "%p%python.exe" EXIT /B 1 +IF NOT EXIST "%p%python.exe" goto :no-python :: Check if %p% is python2 "%p%python.exe" -V 2>&1 | findstr /R "^Python.2.*" > NUL -IF ERRORLEVEL 1 EXIT /B %ERRORLEVEL% +IF ERRORLEVEL 1 goto :no-python2 :: We can wrap it up ENDLOCAL & SET pt=%p%& SET need_path_ext=%need_path% SET VCBUILD_PYTHON_LOCATION=%pt%python.exe IF %need_path_ext%==1 SET Path=%Path%;%pt% SET need_path_ext= -EXIT /B %ERRORLEVEL% \ No newline at end of file +EXIT /B %ERRORLEVEL% + +:no-python2 +echo Python found in %p%, but it is not v2.x. +exit /B 1 +:no-python +echo Could not find Python. +exit /B 1 diff --git a/tools/msvs/vswhere_usability_wrapper.cmd b/tools/msvs/vswhere_usability_wrapper.cmd index a260a50a2c2..4a159baabc0 100644 --- a/tools/msvs/vswhere_usability_wrapper.cmd +++ b/tools/msvs/vswhere_usability_wrapper.cmd @@ -28,5 +28,4 @@ for /f "usebackq tokens=*" %%i in (`vswhere %VSWHERE_ARGS%`) do ( :no-vswhere endlocal -echo could not find "vswhere" exit /B 1 diff --git a/vcbuild.bat b/vcbuild.bat index 88693a71cbd..a6644928319 100644 --- a/vcbuild.bat +++ b/vcbuild.bat @@ -1,4 +1,4 @@ -@echo off +@if not defined DEBUG_HELPER @ECHO OFF cd %~dp0 @@ -166,7 +166,7 @@ if "%target%"=="Clean" rmdir /S /Q %~dp0deps\icu :no-depsicu call tools\msvs\find_python.cmd -if errorlevel 1 echo Could not find python2 & goto :exit +if errorlevel 1 goto :exit call :getnodeversion || exit /b 1 From 8272c225b12eb08f60d41791c68f3f1a28caec20 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 19 Feb 2018 01:49:30 +0100 Subject: [PATCH 22/47] errors: implement new error handling This implements a function based system. Instead of passing in the error code as first argument, the error code itself is a error class. It already contains the correct error type, so while adding a new error no one has to think about the error type anymore. In case a single error code has more than one error type, the error class has properties for the non default error types. Those can be used as fallback. This prevents typos, makes the implementation easier and it is less verbose when writing the code for a new error. The implementation itself does not interfere with the old implementation. So the old and the new system can co-exist and it is possible to slowly migrate the old ones to the new system. PR-URL: https://github.com/nodejs/node/pull/18857 Reviewed-By: Anna Henningsen Reviewed-By: Gus Caplan Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- lib/internal/errors.js | 56 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index 92e1efbf2fb..ea72ea714d8 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -13,6 +13,7 @@ const kCode = Symbol('code'); const kInfo = Symbol('info'); const messages = new Map(); +const codes = {}; var green = ''; var red = ''; @@ -86,6 +87,54 @@ function makeNodeError(Base) { }; } +function makeNodeErrorWithCode(Base, key) { + return class NodeError extends Base { + constructor(...args) { + super(message(key, args)); + } + + get name() { + return `${super.name} [${key}]`; + } + + set name(value) { + defineProperty(this, 'name', { + configurable: true, + enumerable: true, + value, + writable: true + }); + } + + get code() { + return key; + } + + set code(value) { + defineProperty(this, 'code', { + configurable: true, + enumerable: true, + value, + writable: true + }); + } + }; +} + +// Utility function for registering the error codes. Only used here. Exported +// *only* to allow for testing. +function E(sym, val, def, ...otherClasses) { + messages.set(sym, val); + if (def === undefined) return; + def = makeNodeErrorWithCode(def, sym); + if (otherClasses.length !== 0) { + otherClasses.forEach((clazz) => { + def[clazz.name] = makeNodeErrorWithCode(clazz, sym); + }); + } + codes[sym] = def; +} + function lazyBuffer() { if (buffer === undefined) buffer = require('buffer').Buffer; @@ -367,12 +416,6 @@ function message(key, args) { return String(fmt.apply(null, args)); } -// Utility function for registering the error codes. Only used here. Exported -// *only* to allow for testing. -function E(sym, val) { - messages.set(sym, typeof val === 'function' ? val : String(val)); -} - /** * This creates an error compatible with errors produced in the C++ * function UVException using a context object with data assembled in C++. @@ -523,6 +566,7 @@ module.exports = exports = { URIError: makeNodeError(URIError), AssertionError, SystemError, + codes, E, // This is exported only to facilitate testing. errorCache: new Map() // This is in here only to facilitate testing. }; From 6e1c25c45672b70f4b6c6c8af56d9c0762bfae04 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 19 Feb 2018 01:50:56 +0100 Subject: [PATCH 23/47] errors: update all internal errors This updates all internal errors to the new error type. While doing so it removes unused errors. A few errors currently seem to have the wrong type. To identify them later, comments were added next to the error type. PR-URL: https://github.com/nodejs/node/pull/18857 Reviewed-By: Anna Henningsen Reviewed-By: Gus Caplan Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- doc/api/errors.md | 55 ---- lib/internal/errors.js | 403 +++++++++++++------------- test/parallel/test-internal-errors.js | 13 - 3 files changed, 209 insertions(+), 262 deletions(-) diff --git a/doc/api/errors.md b/doc/api/errors.md index 128a3ff68be..dfd3a84d474 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -793,12 +793,6 @@ An invalid symlink type was passed to the [`fs.symlink()`][] or An attempt was made to add more headers after the headers had already been sent. - -### ERR_HTTP_INVALID_CHAR - -An invalid character was found in an HTTP response status message (reason -phrase). - ### ERR_HTTP_INVALID_HEADER_VALUE @@ -815,11 +809,6 @@ Status code was outside the regular status code range (100-999). The `Trailer` header was set even though the transfer encoding does not support that. - -### ERR_HTTP2_ALREADY_SHUTDOWN - -Occurs with multiple attempts to shutdown an HTTP/2 session. - ### ERR_HTTP2_ALTSVC_INVALID_ORIGIN @@ -848,22 +837,12 @@ forbidden. For HTTP/2 requests using the `CONNECT` method, the `:scheme` pseudo-header is forbidden. - -### ERR_HTTP2_FRAME_ERROR - -A failure occurred sending an individual frame on the HTTP/2 session. - ### ERR_HTTP2_GOAWAY_SESSION New HTTP/2 Streams may not be opened after the `Http2Session` has received a `GOAWAY` frame from the connected peer. - -### ERR_HTTP2_HEADER_REQUIRED - -A required header was missing in an HTTP/2 message. - ### ERR_HTTP2_HEADER_SINGLE_VALUE @@ -875,22 +854,11 @@ have only a single value. An additional headers was specified after an HTTP/2 response was initiated. - -### ERR_HTTP2_HEADERS_OBJECT - -An HTTP/2 Headers Object was expected. - ### ERR_HTTP2_HEADERS_SENT An attempt was made to send multiple response headers. - -### ERR_HTTP2_INFO_HEADERS_AFTER_RESPOND - -HTTP/2 Informational headers must only be sent *prior* to calling the -`Http2Stream.prototype.respond()` method. - ### ERR_HTTP2_INFO_STATUS_NOT_ALLOWED @@ -1280,14 +1248,6 @@ strict compliance with the API specification (which in some cases may accept `func(undefined)` and `func()` are treated identically, and the [`ERR_INVALID_ARG_TYPE`][] error code may be used instead. - -### ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK - -> Stability: 1 - Experimental - -An [ES6 module][] loader hook specified `format: 'dynamic` but did not provide a -`dynamicInstantiate` hook. - ### ERR_MISSING_MODULE @@ -1316,11 +1276,6 @@ would be possible by calling a callback more than once. While using `N-API`, a constructor passed was not a function. - -### ERR_NAPI_CONS_PROTOTYPE_OBJECT - -While using `N-API`, `Constructor.prototype` was not an object. - ### ERR_NAPI_INVALID_DATAVIEW_ARGS @@ -1363,11 +1318,6 @@ For example: `Buffer.write(string, encoding, offset[, length])` A given value is out of the accepted range. - -### ERR_PARSE_HISTORY_DATA - -The `REPL` module was unable parse data from the REPL history file. - ### ERR_REQUIRE_ESM @@ -1524,11 +1474,6 @@ recommended to use 2048 bits or larger for stronger security. A TLS/SSL handshake timed out. In this case, the server must also abort the connection. - -### ERR_TLS_RENEGOTIATION_FAILED - -A TLS renegotiation request has failed in a non-specific way. - ### ERR_TLS_REQUIRED_SERVER_NAME diff --git a/lib/internal/errors.js b/lib/internal/errors.js index ea72ea714d8..d3c06b2feba 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -587,134 +587,137 @@ module.exports = exports = { // // Note: Node.js specific errors must begin with the prefix ERR_ -E('ERR_ARG_NOT_ITERABLE', '%s must be iterable'); -E('ERR_ASSERTION', '%s'); -E('ERR_ASYNC_CALLBACK', '%s must be a function'); -E('ERR_ASYNC_TYPE', 'Invalid name for async "type": %s'); -E('ERR_BUFFER_OUT_OF_BOUNDS', bufferOutOfBounds); +E('ERR_ARG_NOT_ITERABLE', '%s must be iterable', TypeError); +E('ERR_ASSERTION', '%s', AssertionError); +E('ERR_ASYNC_CALLBACK', '%s must be a function', TypeError); +E('ERR_ASYNC_TYPE', 'Invalid name for async "type": %s', TypeError); +E('ERR_BUFFER_OUT_OF_BOUNDS', bufferOutOfBounds, RangeError); E('ERR_BUFFER_TOO_LARGE', - `Cannot create a Buffer larger than 0x${kMaxLength.toString(16)} bytes`); -E('ERR_CANNOT_WATCH_SIGINT', 'Cannot watch for SIGINT signals'); -E('ERR_CHILD_CLOSED_BEFORE_REPLY', 'Child closed before reply received'); + `Cannot create a Buffer larger than 0x${kMaxLength.toString(16)} bytes`, + RangeError); +E('ERR_CANNOT_WATCH_SIGINT', 'Cannot watch for SIGINT signals', Error); +E('ERR_CHILD_CLOSED_BEFORE_REPLY', + 'Child closed before reply received', Error); E('ERR_CHILD_PROCESS_IPC_REQUIRED', - "Forked processes must have an IPC channel, missing value 'ipc' in %s"); -E('ERR_CHILD_PROCESS_STDIO_MAXBUFFER', '%s maxBuffer length exceeded'); + "Forked processes must have an IPC channel, missing value 'ipc' in %s", + Error); +E('ERR_CHILD_PROCESS_STDIO_MAXBUFFER', '%s maxBuffer length exceeded', + RangeError); E('ERR_CONSOLE_WRITABLE_STREAM', - 'Console expects a writable stream instance for %s'); -E('ERR_CPU_USAGE', 'Unable to obtain cpu usage %s'); + 'Console expects a writable stream instance for %s', TypeError); +E('ERR_CPU_USAGE', 'Unable to obtain cpu usage %s', Error); E('ERR_CRYPTO_CUSTOM_ENGINE_NOT_SUPPORTED', - 'Custom engines not supported by this OpenSSL'); -E('ERR_CRYPTO_ECDH_INVALID_FORMAT', 'Invalid ECDH format: %s'); + 'Custom engines not supported by this OpenSSL', Error); +E('ERR_CRYPTO_ECDH_INVALID_FORMAT', 'Invalid ECDH format: %s', TypeError); E('ERR_CRYPTO_ECDH_INVALID_PUBLIC_KEY', - 'Public key is not valid for specified curve'); -E('ERR_CRYPTO_ENGINE_UNKNOWN', 'Engine "%s" was not found'); + 'Public key is not valid for specified curve', TypeError); +E('ERR_CRYPTO_ENGINE_UNKNOWN', 'Engine "%s" was not found', Error); E('ERR_CRYPTO_FIPS_FORCED', - 'Cannot set FIPS mode, it was forced with --force-fips at startup.'); -E('ERR_CRYPTO_FIPS_UNAVAILABLE', 'Cannot set FIPS mode in a non-FIPS build.'); -E('ERR_CRYPTO_HASH_DIGEST_NO_UTF16', 'hash.digest() does not support UTF-16'); -E('ERR_CRYPTO_HASH_FINALIZED', 'Digest already called'); -E('ERR_CRYPTO_HASH_UPDATE_FAILED', 'Hash update failed'); -E('ERR_CRYPTO_INVALID_DIGEST', 'Invalid digest: %s'); -E('ERR_CRYPTO_INVALID_STATE', 'Invalid state for operation %s'); -E('ERR_CRYPTO_SIGN_KEY_REQUIRED', 'No key provided to sign'); + 'Cannot set FIPS mode, it was forced with --force-fips at startup.', Error); +E('ERR_CRYPTO_FIPS_UNAVAILABLE', 'Cannot set FIPS mode in a non-FIPS build.', + Error); +E('ERR_CRYPTO_HASH_DIGEST_NO_UTF16', 'hash.digest() does not support UTF-16', + Error); +E('ERR_CRYPTO_HASH_FINALIZED', 'Digest already called', Error); +E('ERR_CRYPTO_HASH_UPDATE_FAILED', 'Hash update failed', Error); +E('ERR_CRYPTO_INVALID_DIGEST', 'Invalid digest: %s', TypeError); +E('ERR_CRYPTO_INVALID_STATE', 'Invalid state for operation %s', Error); +E('ERR_CRYPTO_SIGN_KEY_REQUIRED', 'No key provided to sign', Error); E('ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH', - 'Input buffers must have the same length'); -E('ERR_DNS_SET_SERVERS_FAILED', 'c-ares failed to set servers: "%s" [%s]'); + 'Input buffers must have the same length', RangeError); +E('ERR_DNS_SET_SERVERS_FAILED', 'c-ares failed to set servers: "%s" [%s]', + Error); E('ERR_DOMAIN_CALLBACK_NOT_AVAILABLE', 'A callback was registered through ' + - 'process.setUncaughtExceptionCaptureCallback(), which is mutually ' + - 'exclusive with using the `domain` module'); + 'process.setUncaughtExceptionCaptureCallback(), which is mutually ' + + 'exclusive with using the `domain` module', + Error); E('ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE', 'The `domain` module is in use, which is mutually exclusive with calling ' + - 'process.setUncaughtExceptionCaptureCallback()'); + 'process.setUncaughtExceptionCaptureCallback()', + Error); E('ERR_ENCODING_INVALID_ENCODED_DATA', - 'The encoded data was not valid for encoding %s'); -E('ERR_ENCODING_NOT_SUPPORTED', 'The "%s" encoding is not supported'); -E('ERR_FALSY_VALUE_REJECTION', 'Promise was rejected with falsy value'); + 'The encoded data was not valid for encoding %s', TypeError); +E('ERR_ENCODING_NOT_SUPPORTED', 'The "%s" encoding is not supported', + RangeError); // One entry is currently falsy implemented as "Error" +E('ERR_FALSY_VALUE_REJECTION', 'Promise was rejected with falsy value', Error); E('ERR_FS_INVALID_SYMLINK_TYPE', - 'Symlink type must be one of "dir", "file", or "junction". Received "%s"'); -E('ERR_HTTP2_ALREADY_SHUTDOWN', - 'Http2Session is already shutdown or destroyed'); + 'Symlink type must be one of "dir", "file", or "junction". Received "%s"', + Error); E('ERR_HTTP2_ALTSVC_INVALID_ORIGIN', - 'HTTP/2 ALTSVC frames require a valid origin'); + 'HTTP/2 ALTSVC frames require a valid origin', TypeError); E('ERR_HTTP2_ALTSVC_LENGTH', - 'HTTP/2 ALTSVC frames are limited to 16382 bytes'); + 'HTTP/2 ALTSVC frames are limited to 16382 bytes', TypeError); E('ERR_HTTP2_CONNECT_AUTHORITY', - ':authority header is required for CONNECT requests'); + ':authority header is required for CONNECT requests', Error); E('ERR_HTTP2_CONNECT_PATH', - 'The :path header is forbidden for CONNECT requests'); + 'The :path header is forbidden for CONNECT requests', Error); E('ERR_HTTP2_CONNECT_SCHEME', - 'The :scheme header is forbidden for CONNECT requests'); -E('ERR_HTTP2_FRAME_ERROR', - (type, code, id) => { - let msg = `Error sending frame type ${type}`; - if (id !== undefined) - msg += ` for stream ${id}`; - msg += ` with code ${code}`; - return msg; - }); + 'The :scheme header is forbidden for CONNECT requests', Error); E('ERR_HTTP2_GOAWAY_SESSION', - 'New streams cannot be created after receiving a GOAWAY'); + 'New streams cannot be created after receiving a GOAWAY', Error); E('ERR_HTTP2_HEADERS_AFTER_RESPOND', - 'Cannot specify additional headers after response initiated'); -E('ERR_HTTP2_HEADERS_OBJECT', 'Headers must be an object'); -E('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.'); -E('ERR_HTTP2_HEADER_REQUIRED', 'The %s header is required'); + 'Cannot specify additional headers after response initiated', Error); +E('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.', Error); E('ERR_HTTP2_HEADER_SINGLE_VALUE', - 'Header field "%s" must have only a single value'); -E('ERR_HTTP2_INFO_HEADERS_AFTER_RESPOND', - 'Cannot send informational headers after the HTTP message has been sent'); + 'Header field "%s" must have only a single value', Error); E('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED', - 'Informational status codes cannot be used'); + 'Informational status codes cannot be used', RangeError); E('ERR_HTTP2_INVALID_CONNECTION_HEADERS', - 'HTTP/1 Connection specific headers are forbidden: "%s"'); -E('ERR_HTTP2_INVALID_HEADER_VALUE', 'Invalid value "%s" for header "%s"'); + 'HTTP/1 Connection specific headers are forbidden: "%s"', Error); +E('ERR_HTTP2_INVALID_HEADER_VALUE', + 'Invalid value "%s" for header "%s"', TypeError); E('ERR_HTTP2_INVALID_INFO_STATUS', - 'Invalid informational status code: %s'); + 'Invalid informational status code: %s', RangeError); E('ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH', - 'Packed settings length must be a multiple of six'); + 'Packed settings length must be a multiple of six', RangeError); E('ERR_HTTP2_INVALID_PSEUDOHEADER', - '"%s" is an invalid pseudoheader or is used incorrectly'); -E('ERR_HTTP2_INVALID_SESSION', 'The session has been destroyed'); + '"%s" is an invalid pseudoheader or is used incorrectly', Error); +E('ERR_HTTP2_INVALID_SESSION', 'The session has been destroyed', Error); E('ERR_HTTP2_INVALID_SETTING_VALUE', - 'Invalid value for setting "%s": %s'); -E('ERR_HTTP2_INVALID_STREAM', 'The stream has been destroyed'); + 'Invalid value for setting "%s": %s', TypeError, RangeError); +E('ERR_HTTP2_INVALID_STREAM', 'The stream has been destroyed', Error); E('ERR_HTTP2_MAX_PENDING_SETTINGS_ACK', - 'Maximum number of pending settings acknowledgements (%s)'); + 'Maximum number of pending settings acknowledgements (%s)', Error); E('ERR_HTTP2_NO_SOCKET_MANIPULATION', - 'HTTP/2 sockets should not be directly manipulated (e.g. read and written)'); + 'HTTP/2 sockets should not be directly manipulated (e.g. read and written)', + Error); E('ERR_HTTP2_OUT_OF_STREAMS', - 'No stream ID is available because maximum stream ID has been reached'); + 'No stream ID is available because maximum stream ID has been reached', + Error); E('ERR_HTTP2_PAYLOAD_FORBIDDEN', - 'Responses with %s status must not have a payload'); -E('ERR_HTTP2_PING_CANCEL', 'HTTP2 ping cancelled'); -E('ERR_HTTP2_PING_LENGTH', 'HTTP2 ping payload must be 8 bytes'); -E('ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED', 'Cannot set HTTP/2 pseudo-headers'); -E('ERR_HTTP2_PUSH_DISABLED', 'HTTP/2 client has disabled push streams'); -E('ERR_HTTP2_SEND_FILE', 'Only regular files can be sent'); -E('ERR_HTTP2_SESSION_ERROR', 'Session closed with error code %s'); + 'Responses with %s status must not have a payload', Error); +E('ERR_HTTP2_PING_CANCEL', 'HTTP2 ping cancelled', Error); +E('ERR_HTTP2_PING_LENGTH', 'HTTP2 ping payload must be 8 bytes', RangeError); +E('ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED', + 'Cannot set HTTP/2 pseudo-headers', Error); +E('ERR_HTTP2_PUSH_DISABLED', 'HTTP/2 client has disabled push streams', Error); +E('ERR_HTTP2_SEND_FILE', 'Only regular files can be sent', Error); +E('ERR_HTTP2_SESSION_ERROR', 'Session closed with error code %s', Error); E('ERR_HTTP2_SOCKET_BOUND', - 'The socket is already bound to an Http2Session'); + 'The socket is already bound to an Http2Session', Error); E('ERR_HTTP2_STATUS_101', - 'HTTP status code 101 (Switching Protocols) is forbidden in HTTP/2'); -E('ERR_HTTP2_STATUS_INVALID', 'Invalid status code: %s'); -E('ERR_HTTP2_STREAM_CANCEL', 'The pending stream has been canceled'); -E('ERR_HTTP2_STREAM_ERROR', 'Stream closed with error code %s'); -E('ERR_HTTP2_STREAM_SELF_DEPENDENCY', 'A stream cannot depend on itself'); -E('ERR_HTTP2_UNSUPPORTED_PROTOCOL', 'protocol "%s" is unsupported.'); + 'HTTP status code 101 (Switching Protocols) is forbidden in HTTP/2', Error); +E('ERR_HTTP2_STATUS_INVALID', 'Invalid status code: %s', RangeError); +E('ERR_HTTP2_STREAM_CANCEL', 'The pending stream has been canceled', Error); +E('ERR_HTTP2_STREAM_ERROR', 'Stream closed with error code %s', Error); +E('ERR_HTTP2_STREAM_SELF_DEPENDENCY', + 'A stream cannot depend on itself', Error); +E('ERR_HTTP2_UNSUPPORTED_PROTOCOL', 'protocol "%s" is unsupported.', Error); E('ERR_HTTP_HEADERS_SENT', - 'Cannot %s headers after they are sent to the client'); -E('ERR_HTTP_INVALID_CHAR', 'Invalid character in statusMessage.'); -E('ERR_HTTP_INVALID_HEADER_VALUE', 'Invalid value "%s" for header "%s"'); -E('ERR_HTTP_INVALID_STATUS_CODE', 'Invalid status code: %s'); + 'Cannot %s headers after they are sent to the client', Error); +E('ERR_HTTP_INVALID_HEADER_VALUE', + 'Invalid value "%s" for header "%s"', TypeError); +E('ERR_HTTP_INVALID_STATUS_CODE', 'Invalid status code: %s', RangeError); E('ERR_HTTP_TRAILER_INVALID', - 'Trailers are invalid with this transfer encoding'); -E('ERR_INDEX_OUT_OF_RANGE', 'Index out of range'); -E('ERR_INSPECTOR_ALREADY_CONNECTED', 'The inspector is already connected'); -E('ERR_INSPECTOR_CLOSED', 'Session was closed'); -E('ERR_INSPECTOR_NOT_AVAILABLE', 'Inspector is not available'); -E('ERR_INSPECTOR_NOT_CONNECTED', 'Session is not connected'); -E('ERR_INVALID_ARG_TYPE', invalidArgType); + 'Trailers are invalid with this transfer encoding', Error); +E('ERR_INDEX_OUT_OF_RANGE', 'Index out of range', RangeError); +E('ERR_INSPECTOR_ALREADY_CONNECTED', + 'The inspector is already connected', Error); +E('ERR_INSPECTOR_CLOSED', 'Session was closed', Error); +E('ERR_INSPECTOR_NOT_AVAILABLE', 'Inspector is not available', Error); +E('ERR_INSPECTOR_NOT_CONNECTED', 'Session is not connected', Error); +E('ERR_INVALID_ARG_TYPE', invalidArgType, TypeError); E('ERR_INVALID_ARG_VALUE', (name, value, reason = 'is invalid') => { const util = lazyUtil(); let inspected = util.inspect(value); @@ -722,141 +725,153 @@ E('ERR_INVALID_ARG_VALUE', (name, value, reason = 'is invalid') => { inspected = inspected.slice(0, 128) + '...'; } return `The argument '${name}' ${reason}. Received ${inspected}`; -}), +}, TypeError, RangeError); // Some are currently falsy implemented as "Error" E('ERR_INVALID_ARRAY_LENGTH', (name, len, actual) => { internalAssert(typeof actual === 'number', 'actual must be a number'); return `The array "${name}" (length ${actual}) must be of length ${len}.`; - }); -E('ERR_INVALID_ASYNC_ID', 'Invalid %s value: %s'); -E('ERR_INVALID_BUFFER_SIZE', 'Buffer size must be a multiple of %s'); -E('ERR_INVALID_CALLBACK', 'Callback must be a function'); -E('ERR_INVALID_CHAR', invalidChar); + }, TypeError); +E('ERR_INVALID_ASYNC_ID', 'Invalid %s value: %s', RangeError); +E('ERR_INVALID_BUFFER_SIZE', + 'Buffer size must be a multiple of %s', RangeError); +E('ERR_INVALID_CALLBACK', 'Callback must be a function', TypeError); +E('ERR_INVALID_CHAR', invalidChar, TypeError); //Check falsy "Error" entries. E('ERR_INVALID_CURSOR_POS', - 'Cannot set cursor row without setting its column'); -E('ERR_INVALID_DOMAIN_NAME', 'Unable to determine the domain name'); -E('ERR_INVALID_FD', '"fd" must be a positive integer: %s'); -E('ERR_INVALID_FD_TYPE', 'Unsupported fd type: %s'); + 'Cannot set cursor row without setting its column', Error); +E('ERR_INVALID_DOMAIN_NAME', 'Unable to determine the domain name', Error); +E('ERR_INVALID_FD', + '"fd" must be a positive integer: %s', RangeError); +E('ERR_INVALID_FD_TYPE', 'Unsupported fd type: %s', TypeError); E('ERR_INVALID_FILE_URL_HOST', - 'File URL host must be "localhost" or empty on %s'); -E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s'); -E('ERR_INVALID_HANDLE_TYPE', 'This handle type cannot be sent'); -E('ERR_INVALID_HTTP_TOKEN', '%s must be a valid HTTP token ["%s"]'); -E('ERR_INVALID_IP_ADDRESS', 'Invalid IP address: %s'); + 'File URL host must be "localhost" or empty on %s', TypeError); +E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s', TypeError); +E('ERR_INVALID_HANDLE_TYPE', 'This handle type cannot be sent', TypeError); +E('ERR_INVALID_HTTP_TOKEN', '%s must be a valid HTTP token ["%s"]', TypeError); +E('ERR_INVALID_IP_ADDRESS', 'Invalid IP address: %s', TypeError, Error); E('ERR_INVALID_OPT_VALUE', (name, value) => - `The value "${String(value)}" is invalid for option "${name}"`); + `The value "${String(value)}" is invalid for option "${name}"`, + TypeError, + RangeError); E('ERR_INVALID_OPT_VALUE_ENCODING', - 'The value "%s" is invalid for option "encoding"'); -E('ERR_INVALID_PERFORMANCE_MARK', 'The "%s" performance mark has not been set'); -E('ERR_INVALID_PROTOCOL', 'Protocol "%s" not supported. Expected "%s"'); + 'The value "%s" is invalid for option "encoding"', TypeError); +E('ERR_INVALID_PERFORMANCE_MARK', + 'The "%s" performance mark has not been set', Error); +E('ERR_INVALID_PROTOCOL', 'Protocol "%s" not supported. Expected "%s"', Error); E('ERR_INVALID_REPL_EVAL_CONFIG', - 'Cannot specify both "breakEvalOnSigint" and "eval" for REPL'); + 'Cannot specify both "breakEvalOnSigint" and "eval" for REPL', Error); E('ERR_INVALID_SYNC_FORK_INPUT', - 'Asynchronous forks do not support Buffer, Uint8Array or string input: %s'); -E('ERR_INVALID_THIS', 'Value of "this" must be of type %s'); -E('ERR_INVALID_TUPLE', '%s must be an iterable %s tuple'); -E('ERR_INVALID_URI', 'URI malformed'); -E('ERR_INVALID_URL', 'Invalid URL: %s'); + 'Asynchronous forks do not support Buffer, Uint8Array or string input: %s', + TypeError); +E('ERR_INVALID_THIS', 'Value of "this" must be of type %s', TypeError); +E('ERR_INVALID_TUPLE', '%s must be an iterable %s tuple', TypeError); +E('ERR_INVALID_URI', 'URI malformed', URIError); +E('ERR_INVALID_URL', 'Invalid URL: %s', TypeError); E('ERR_INVALID_URL_SCHEME', - (expected) => `The URL must be ${oneOf(expected, 'scheme')}`); -E('ERR_IPC_CHANNEL_CLOSED', 'Channel closed'); -E('ERR_IPC_DISCONNECTED', 'IPC channel is already disconnected'); -E('ERR_IPC_ONE_PIPE', 'Child process can have only one IPC pipe'); -E('ERR_IPC_SYNC_FORK', 'IPC cannot be used with synchronous forks'); -E('ERR_METHOD_NOT_IMPLEMENTED', 'The %s method is not implemented'); -E('ERR_MISSING_ARGS', missingArgs); -E('ERR_MISSING_DYNAMIC_INSTANTIATE_HOOK', - 'The ES Module loader may not return a format of \'dynamic\' when no ' + - 'dynamicInstantiate function was provided'); -E('ERR_MISSING_MODULE', 'Cannot find module %s'); -E('ERR_MODULE_RESOLUTION_LEGACY', '%s not found by import in %s.' + - ' Legacy behavior in require() would have found it at %s'); -E('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times'); -E('ERR_NAPI_CONS_FUNCTION', 'Constructor must be a function'); -E('ERR_NAPI_CONS_PROTOTYPE_OBJECT', 'Constructor.prototype must be an object'); + (expected) => `The URL must be ${oneOf(expected, 'scheme')}`, TypeError); +E('ERR_IPC_CHANNEL_CLOSED', 'Channel closed', Error); +E('ERR_IPC_DISCONNECTED', 'IPC channel is already disconnected', Error); +E('ERR_IPC_ONE_PIPE', 'Child process can have only one IPC pipe', Error); +E('ERR_IPC_SYNC_FORK', 'IPC cannot be used with synchronous forks', Error); +E('ERR_METHOD_NOT_IMPLEMENTED', 'The %s method is not implemented', Error); +E('ERR_MISSING_ARGS', missingArgs, TypeError); +E('ERR_MISSING_MODULE', 'Cannot find module %s', Error); +E('ERR_MODULE_RESOLUTION_LEGACY', + '%s not found by import in %s.' + + ' Legacy behavior in require() would have found it at %s', + Error); +E('ERR_MULTIPLE_CALLBACK', 'Callback called multiple times', Error); +E('ERR_NAPI_CONS_FUNCTION', 'Constructor must be a function', TypeError); E('ERR_NAPI_INVALID_DATAVIEW_ARGS', 'byte_offset + byte_length should be less than or eqaul to the size in ' + - 'bytes of the array passed in'); -E('ERR_NAPI_INVALID_TYPEDARRAY_ALIGNMENT', 'start offset of %s should be a ' + - 'multiple of %s'); -E('ERR_NAPI_INVALID_TYPEDARRAY_LENGTH', 'Invalid typed array length'); -E('ERR_NO_CRYPTO', 'Node.js is not compiled with OpenSSL crypto support'); -E('ERR_NO_ICU', '%s is not supported on Node.js compiled without ICU'); -E('ERR_NO_LONGER_SUPPORTED', '%s is no longer supported'); -E('ERR_OUT_OF_RANGE', outOfRange); -E('ERR_PARSE_HISTORY_DATA', 'Could not parse history data in %s'); -E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s'); + 'bytes of the array passed in', + RangeError); +E('ERR_NAPI_INVALID_TYPEDARRAY_ALIGNMENT', + 'start offset of %s should be a multiple of %s', RangeError); +E('ERR_NAPI_INVALID_TYPEDARRAY_LENGTH', + 'Invalid typed array length', RangeError); +E('ERR_NO_CRYPTO', + 'Node.js is not compiled with OpenSSL crypto support', Error); +E('ERR_NO_ICU', + '%s is not supported on Node.js compiled without ICU', TypeError); +E('ERR_NO_LONGER_SUPPORTED', '%s is no longer supported', Error); +E('ERR_OUT_OF_RANGE', outOfRange, RangeError); +E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s', Error); E('ERR_SCRIPT_EXECUTION_INTERRUPTED', - 'Script execution was interrupted by `SIGINT`.'); + 'Script execution was interrupted by `SIGINT`.', Error); E('ERR_SERVER_ALREADY_LISTEN', - 'Listen method has been called more than once without closing.'); -E('ERR_SERVER_NOT_RUNNING', 'Server is not running.'); -E('ERR_SOCKET_ALREADY_BOUND', 'Socket is already bound'); -E('ERR_SOCKET_BAD_BUFFER_SIZE', 'Buffer size must be a positive integer'); -E('ERR_SOCKET_BAD_PORT', 'Port should be > 0 and < 65536. Received %s.'); + 'Listen method has been called more than once without closing.', Error); +E('ERR_SERVER_NOT_RUNNING', 'Server is not running.', Error); +E('ERR_SOCKET_ALREADY_BOUND', 'Socket is already bound', Error); +E('ERR_SOCKET_BAD_BUFFER_SIZE', + 'Buffer size must be a positive integer', TypeError); +E('ERR_SOCKET_BAD_PORT', + 'Port should be > 0 and < 65536. Received %s.', RangeError); E('ERR_SOCKET_BAD_TYPE', - 'Bad socket type specified. Valid types are: udp4, udp6'); -E('ERR_SOCKET_BUFFER_SIZE', 'Could not get or set buffer size: %s'); -E('ERR_SOCKET_CANNOT_SEND', 'Unable to send data'); -E('ERR_SOCKET_CLOSED', 'Socket is closed'); -E('ERR_SOCKET_DGRAM_NOT_RUNNING', 'Not running'); -E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed'); -E('ERR_STDOUT_CLOSE', 'process.stdout cannot be closed'); -E('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable'); -E('ERR_STREAM_NULL_VALUES', 'May not write null values to stream'); -E('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF'); -E('ERR_STREAM_READ_NOT_IMPLEMENTED', '_read() is not implemented'); -E('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event'); -E('ERR_STREAM_WRAP', 'Stream has StringDecoder set or is in objectMode'); -E('ERR_STREAM_WRITE_AFTER_END', 'write after end'); + 'Bad socket type specified. Valid types are: udp4, udp6', TypeError); +E('ERR_SOCKET_BUFFER_SIZE', 'Could not get or set buffer size: %s', Error); +E('ERR_SOCKET_CANNOT_SEND', 'Unable to send data', Error); +E('ERR_SOCKET_CLOSED', 'Socket is closed', Error); +E('ERR_SOCKET_DGRAM_NOT_RUNNING', 'Not running', Error); +E('ERR_STDERR_CLOSE', 'process.stderr cannot be closed', Error); +E('ERR_STDOUT_CLOSE', 'process.stdout cannot be closed', Error); +E('ERR_STREAM_CANNOT_PIPE', 'Cannot pipe, not readable', Error); +E('ERR_STREAM_NULL_VALUES', 'May not write null values to stream', TypeError); +E('ERR_STREAM_PUSH_AFTER_EOF', 'stream.push() after EOF', Error); +E('ERR_STREAM_READ_NOT_IMPLEMENTED', '_read() is not implemented', Error); +E('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', + 'stream.unshift() after end event', Error); +E('ERR_STREAM_WRAP', 'Stream has StringDecoder set or is in objectMode', Error); +E('ERR_STREAM_WRITE_AFTER_END', 'write after end', Error); E('ERR_SYSTEM_ERROR', sysError('A system error occurred')); E('ERR_TLS_CERT_ALTNAME_INVALID', - 'Hostname/IP does not match certificate\'s altnames: %s'); -E('ERR_TLS_DH_PARAM_SIZE', 'DH parameter size %s is less than 2048'); -E('ERR_TLS_HANDSHAKE_TIMEOUT', 'TLS handshake timeout'); + 'Hostname/IP does not match certificate\'s altnames: %s', Error); +E('ERR_TLS_DH_PARAM_SIZE', 'DH parameter size %s is less than 2048', Error); +E('ERR_TLS_HANDSHAKE_TIMEOUT', 'TLS handshake timeout', Error); E('ERR_TLS_RENEGOTIATION_DISABLED', - 'TLS session renegotiation disabled for this socket'); -E('ERR_TLS_RENEGOTIATION_FAILED', 'Failed to renegotiate'); + 'TLS session renegotiation disabled for this socket', Error); E('ERR_TLS_REQUIRED_SERVER_NAME', - '"servername" is required parameter for Server.addContext'); -E('ERR_TLS_SESSION_ATTACK', 'TLS session renegotiation attack detected'); + '"servername" is required parameter for Server.addContext', Error); +E('ERR_TLS_SESSION_ATTACK', 'TLS session renegotiation attack detected', Error); E('ERR_TLS_SNI_FROM_SERVER', - 'Cannot issue SNI from a TLS server-side socket'); + 'Cannot issue SNI from a TLS server-side socket', Error); E('ERR_TRANSFORM_ALREADY_TRANSFORMING', - 'Calling transform done when still transforming'); + 'Calling transform done when still transforming', Error); E('ERR_TRANSFORM_WITH_LENGTH_0', - 'Calling transform done when writableState.length != 0'); + 'Calling transform done when writableState.length != 0', Error); E('ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET', '`process.setupUncaughtExceptionCapture()` was called while a capture ' + - 'callback was already active'); -E('ERR_UNESCAPED_CHARACTERS', '%s contains unescaped characters'); + 'callback was already active', + Error); +E('ERR_UNESCAPED_CHARACTERS', '%s contains unescaped characters', TypeError); E('ERR_UNHANDLED_ERROR', (err) => { const msg = 'Unhandled error.'; if (err === undefined) return msg; return `${msg} (${err})`; - }); -E('ERR_UNKNOWN_ENCODING', 'Unknown encoding: %s'); -E('ERR_UNKNOWN_FILE_EXTENSION', 'Unknown file extension: %s'); -E('ERR_UNKNOWN_MODULE_FORMAT', 'Unknown module format: %s'); -E('ERR_UNKNOWN_SIGNAL', 'Unknown signal: %s'); -E('ERR_UNKNOWN_STDIN_TYPE', 'Unknown stdin file type'); -E('ERR_UNKNOWN_STREAM_TYPE', 'Unknown stream file type'); -E('ERR_V8BREAKITERATOR', 'Full ICU data not installed. ' + - 'See https://github.com/nodejs/node/wiki/Intl'); + }, Error); +E('ERR_UNKNOWN_ENCODING', 'Unknown encoding: %s', TypeError); +E('ERR_UNKNOWN_FILE_EXTENSION', 'Unknown file extension: %s', Error); +E('ERR_UNKNOWN_MODULE_FORMAT', 'Unknown module format: %s', RangeError); +E('ERR_UNKNOWN_SIGNAL', 'Unknown signal: %s', TypeError); +E('ERR_UNKNOWN_STDIN_TYPE', 'Unknown stdin file type', Error); +E('ERR_UNKNOWN_STREAM_TYPE', 'Unknown stream file type', Error); +E('ERR_V8BREAKITERATOR', + 'Full ICU data not installed. See https://github.com/nodejs/node/wiki/Intl', + Error); E('ERR_VALID_PERFORMANCE_ENTRY_TYPE', - 'At least one valid performance entry type is required'); -E('ERR_VM_MODULE_ALREADY_LINKED', 'Module has already been linked'); + 'At least one valid performance entry type is required', Error); +E('ERR_VM_MODULE_ALREADY_LINKED', 'Module has already been linked', Error); E('ERR_VM_MODULE_DIFFERENT_CONTEXT', - 'Linked modules must use the same context'); + 'Linked modules must use the same context', Error); E('ERR_VM_MODULE_LINKING_ERRORED', - 'Linking has already failed for the provided module'); + 'Linking has already failed for the provided module', Error); E('ERR_VM_MODULE_NOT_LINKED', - 'Module must be linked before it can be instantiated'); -E('ERR_VM_MODULE_NOT_MODULE', 'Provided module is not an instance of Module'); -E('ERR_VM_MODULE_STATUS', 'Module status %s'); -E('ERR_ZLIB_BINDING_CLOSED', 'zlib binding closed'); -E('ERR_ZLIB_INITIALIZATION_FAILED', 'Initialization failed'); + 'Module must be linked before it can be instantiated', Error); +E('ERR_VM_MODULE_NOT_MODULE', + 'Provided module is not an instance of Module', Error); +E('ERR_VM_MODULE_STATUS', 'Module status %s', Error); +E('ERR_ZLIB_BINDING_CLOSED', 'zlib binding closed', Error); +E('ERR_ZLIB_INITIALIZATION_FAILED', 'Initialization failed', Error); function sysError(defaultMessage) { return function(code, diff --git a/test/parallel/test-internal-errors.js b/test/parallel/test-internal-errors.js index cdac3960827..9bce8a59eaf 100644 --- a/test/parallel/test-internal-errors.js +++ b/test/parallel/test-internal-errors.js @@ -305,19 +305,6 @@ assert.strictEqual( errors.message('ERR_ENCODING_NOT_SUPPORTED', ['enc']), 'The "enc" encoding is not supported'); -// Test ERR_HTTP2_HEADER_REQUIRED -assert.strictEqual( - errors.message('ERR_HTTP2_HEADER_REQUIRED', ['test']), - 'The test header is required'); - -// Test ERR_HTTP2_FRAME_ERROR -assert.strictEqual( - errors.message('ERR_HTTP2_FRAME_ERROR', ['foo', 'bar', 'baz']), - 'Error sending frame type foo for stream baz with code bar'); -assert.strictEqual( - errors.message('ERR_HTTP2_FRAME_ERROR', ['foo', 'bar']), - 'Error sending frame type foo with code bar'); - // Test error messages for async_hooks assert.strictEqual( errors.message('ERR_ASYNC_CALLBACK', ['init']), From 7c8beb5b5f35875811d6e44e9a03907c03a39bb5 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 19 Feb 2018 01:51:58 +0100 Subject: [PATCH 24/47] console: port errors to new system This ports the errors to the new error system. PR-URL: https://github.com/nodejs/node/pull/18857 Reviewed-By: Anna Henningsen Reviewed-By: Gus Caplan Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- lib/console.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/console.js b/lib/console.js index e216934a7f7..b77832b9876 100644 --- a/lib/console.js +++ b/lib/console.js @@ -21,7 +21,7 @@ 'use strict'; -const errors = require('internal/errors'); +const { ERR_CONSOLE_WRITABLE_STREAM } = require('internal/errors').codes; const util = require('util'); const kCounts = Symbol('counts'); @@ -35,12 +35,12 @@ function Console(stdout, stderr, ignoreErrors = true) { return new Console(stdout, stderr, ignoreErrors); } if (!stdout || typeof stdout.write !== 'function') { - throw new errors.TypeError('ERR_CONSOLE_WRITABLE_STREAM', 'stdout'); + throw new ERR_CONSOLE_WRITABLE_STREAM('stdout'); } if (!stderr) { stderr = stdout; } else if (typeof stderr.write !== 'function') { - throw new errors.TypeError('ERR_CONSOLE_WRITABLE_STREAM', 'stderr'); + throw new ERR_CONSOLE_WRITABLE_STREAM('stderr'); } var prop = { From eb3edefb70f80de23be6c06bf10904048fd369fd Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 19 Feb 2018 02:20:46 +0100 Subject: [PATCH 25/47] errors: add comments about falsy error types Some error types are not properly set. This adds comments which ones are probably falty and to what they should be set instead. PR-URL: https://github.com/nodejs/node/pull/18857 Reviewed-By: Anna Henningsen Reviewed-By: Gus Caplan Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- lib/internal/errors.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index d3c06b2feba..a170c349aee 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -622,6 +622,8 @@ E('ERR_CRYPTO_HASH_FINALIZED', 'Digest already called', Error); E('ERR_CRYPTO_HASH_UPDATE_FAILED', 'Hash update failed', Error); E('ERR_CRYPTO_INVALID_DIGEST', 'Invalid digest: %s', TypeError); E('ERR_CRYPTO_INVALID_STATE', 'Invalid state for operation %s', Error); + +// Switch to TypeError. The current implementation does not seem right. E('ERR_CRYPTO_SIGN_KEY_REQUIRED', 'No key provided to sign', Error); E('ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH', 'Input buffers must have the same length', RangeError); @@ -643,7 +645,7 @@ E('ERR_ENCODING_NOT_SUPPORTED', 'The "%s" encoding is not supported', E('ERR_FALSY_VALUE_REJECTION', 'Promise was rejected with falsy value', Error); E('ERR_FS_INVALID_SYMLINK_TYPE', 'Symlink type must be one of "dir", "file", or "junction". Received "%s"', - Error); + Error); // Switch to TypeError. The current implementation does not seem right E('ERR_HTTP2_ALTSVC_INVALID_ORIGIN', 'HTTP/2 ALTSVC frames require a valid origin', TypeError); E('ERR_HTTP2_ALTSVC_LENGTH', @@ -659,10 +661,14 @@ E('ERR_HTTP2_GOAWAY_SESSION', E('ERR_HTTP2_HEADERS_AFTER_RESPOND', 'Cannot specify additional headers after response initiated', Error); E('ERR_HTTP2_HEADERS_SENT', 'Response has already been initiated.', Error); + +// This should probably be a `TypeError`. E('ERR_HTTP2_HEADER_SINGLE_VALUE', 'Header field "%s" must have only a single value', Error); E('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED', 'Informational status codes cannot be used', RangeError); + +// This should probably be a `TypeError`. E('ERR_HTTP2_INVALID_CONNECTION_HEADERS', 'HTTP/1 Connection specific headers are forbidden: "%s"', Error); E('ERR_HTTP2_INVALID_HEADER_VALUE', @@ -671,6 +677,8 @@ E('ERR_HTTP2_INVALID_INFO_STATUS', 'Invalid informational status code: %s', RangeError); E('ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH', 'Packed settings length must be a multiple of six', RangeError); + +// This should probably be a `TypeError`. E('ERR_HTTP2_INVALID_PSEUDOHEADER', '"%s" is an invalid pseudoheader or is used incorrectly', Error); E('ERR_HTTP2_INVALID_SESSION', 'The session has been destroyed', Error); @@ -689,6 +697,8 @@ E('ERR_HTTP2_PAYLOAD_FORBIDDEN', 'Responses with %s status must not have a payload', Error); E('ERR_HTTP2_PING_CANCEL', 'HTTP2 ping cancelled', Error); E('ERR_HTTP2_PING_LENGTH', 'HTTP2 ping payload must be 8 bytes', RangeError); + +// This should probably be a `TypeError`. E('ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED', 'Cannot set HTTP/2 pseudo-headers', Error); E('ERR_HTTP2_PUSH_DISABLED', 'HTTP/2 client has disabled push streams', Error); @@ -736,8 +746,12 @@ E('ERR_INVALID_BUFFER_SIZE', 'Buffer size must be a multiple of %s', RangeError); E('ERR_INVALID_CALLBACK', 'Callback must be a function', TypeError); E('ERR_INVALID_CHAR', invalidChar, TypeError); //Check falsy "Error" entries. + +// This should probably be a `TypeError`. E('ERR_INVALID_CURSOR_POS', 'Cannot set cursor row without setting its column', Error); + +// This should probably be a `TypeError`. E('ERR_INVALID_DOMAIN_NAME', 'Unable to determine the domain name', Error); E('ERR_INVALID_FD', '"fd" must be a positive integer: %s', RangeError); @@ -747,6 +761,7 @@ E('ERR_INVALID_FILE_URL_HOST', E('ERR_INVALID_FILE_URL_PATH', 'File URL path %s', TypeError); E('ERR_INVALID_HANDLE_TYPE', 'This handle type cannot be sent', TypeError); E('ERR_INVALID_HTTP_TOKEN', '%s must be a valid HTTP token ["%s"]', TypeError); +// The `Error` should probably be a `TypeError`. E('ERR_INVALID_IP_ADDRESS', 'Invalid IP address: %s', TypeError, Error); E('ERR_INVALID_OPT_VALUE', (name, value) => `The value "${String(value)}" is invalid for option "${name}"`, @@ -756,7 +771,11 @@ E('ERR_INVALID_OPT_VALUE_ENCODING', 'The value "%s" is invalid for option "encoding"', TypeError); E('ERR_INVALID_PERFORMANCE_MARK', 'The "%s" performance mark has not been set', Error); + +// This should probably be a `TypeError`. E('ERR_INVALID_PROTOCOL', 'Protocol "%s" not supported. Expected "%s"', Error); + +// This should probably be a `TypeError`. E('ERR_INVALID_REPL_EVAL_CONFIG', 'Cannot specify both "breakEvalOnSigint" and "eval" for REPL', Error); E('ERR_INVALID_SYNC_FORK_INPUT', @@ -829,6 +848,8 @@ E('ERR_TLS_DH_PARAM_SIZE', 'DH parameter size %s is less than 2048', Error); E('ERR_TLS_HANDSHAKE_TIMEOUT', 'TLS handshake timeout', Error); E('ERR_TLS_RENEGOTIATION_DISABLED', 'TLS session renegotiation disabled for this socket', Error); + +// This should probably be a `TypeError`. E('ERR_TLS_REQUIRED_SERVER_NAME', '"servername" is required parameter for Server.addContext', Error); E('ERR_TLS_SESSION_ATTACK', 'TLS session renegotiation attack detected', Error); @@ -836,6 +857,8 @@ E('ERR_TLS_SNI_FROM_SERVER', 'Cannot issue SNI from a TLS server-side socket', Error); E('ERR_TRANSFORM_ALREADY_TRANSFORMING', 'Calling transform done when still transforming', Error); + +// This should probably be a `RangeError`. E('ERR_TRANSFORM_WITH_LENGTH_0', 'Calling transform done when writableState.length != 0', Error); E('ERR_UNCAUGHT_EXCEPTION_CAPTURE_ALREADY_SET', @@ -850,14 +873,20 @@ E('ERR_UNHANDLED_ERROR', return `${msg} (${err})`; }, Error); E('ERR_UNKNOWN_ENCODING', 'Unknown encoding: %s', TypeError); + +// This should probably be a `TypeError`. E('ERR_UNKNOWN_FILE_EXTENSION', 'Unknown file extension: %s', Error); E('ERR_UNKNOWN_MODULE_FORMAT', 'Unknown module format: %s', RangeError); E('ERR_UNKNOWN_SIGNAL', 'Unknown signal: %s', TypeError); E('ERR_UNKNOWN_STDIN_TYPE', 'Unknown stdin file type', Error); + +// This should probably be a `TypeError`. E('ERR_UNKNOWN_STREAM_TYPE', 'Unknown stream file type', Error); E('ERR_V8BREAKITERATOR', 'Full ICU data not installed. See https://github.com/nodejs/node/wiki/Intl', Error); + +// This should probably be a `TypeError`. E('ERR_VALID_PERFORMANCE_ENTRY_TYPE', 'At least one valid performance entry type is required', Error); E('ERR_VM_MODULE_ALREADY_LINKED', 'Module has already been linked', Error); From 95bae858094450bd01f858ddd358ae0f83865157 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Mon, 19 Feb 2018 02:25:54 +0100 Subject: [PATCH 26/47] errors: simplify sysError PR-URL: https://github.com/nodejs/node/pull/18857 Reviewed-By: Anna Henningsen Reviewed-By: Gus Caplan Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- lib/internal/errors.js | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index a170c349aee..9816474d7a0 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -841,7 +841,7 @@ E('ERR_STREAM_UNSHIFT_AFTER_END_EVENT', 'stream.unshift() after end event', Error); E('ERR_STREAM_WRAP', 'Stream has StringDecoder set or is in objectMode', Error); E('ERR_STREAM_WRITE_AFTER_END', 'write after end', Error); -E('ERR_SYSTEM_ERROR', sysError('A system error occurred')); +E('ERR_SYSTEM_ERROR', sysError); E('ERR_TLS_CERT_ALTNAME_INVALID', 'Hostname/IP does not match certificate\'s altnames: %s', Error); E('ERR_TLS_DH_PARAM_SIZE', 'DH parameter size %s is less than 2048', Error); @@ -902,26 +902,21 @@ E('ERR_VM_MODULE_STATUS', 'Module status %s', Error); E('ERR_ZLIB_BINDING_CLOSED', 'zlib binding closed', Error); E('ERR_ZLIB_INITIALIZATION_FAILED', 'Initialization failed', Error); -function sysError(defaultMessage) { - return function(code, - syscall, - path, - dest, - message = defaultMessage) { - if (code !== undefined) - message += `: ${code}`; - if (syscall !== undefined) { - if (code === undefined) - message += ':'; - message += ` [${syscall}]`; - } - if (path !== undefined) { - message += `: ${path}`; - if (dest !== undefined) - message += ` => ${dest}`; - } - return message; - }; +function sysError(code, syscall, path, dest, + message = 'A system error occurred') { + if (code !== undefined) + message += `: ${code}`; + if (syscall !== undefined) { + if (code === undefined) + message += ':'; + message += ` [${syscall}]`; + } + if (path !== undefined) { + message += `: ${path}`; + if (dest !== undefined) + message += ` => ${dest}`; + } + return message; } function invalidArgType(name, expected, actual) { From 13637d23f7a2667c2f9abfe2c1a44d6941e10681 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 22 Feb 2018 12:50:50 +0100 Subject: [PATCH 27/47] tools: add falsely removed eslint rules This adds the eslint rules back in that were falsely removed while landing https://github.com/nodejs/node/pull/18566. PR-URL: https://github.com/nodejs/node/pull/18933 Refs: https://github.com/nodejs/node/pull/18566 Reviewed-By: Matteo Collina Reviewed-By: James M Snell Reviewed-By: Gus Caplan Reviewed-By: Colin Ihrig --- .eslintrc.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.eslintrc.js b/.eslintrc.js index 7b8a2cc8334..cd5fc51e8e3 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -71,6 +71,7 @@ module.exports = { 'accessor-pairs': 'error', 'array-callback-return': 'error', 'dot-location': ['error', 'property'], + 'dot-notation': 'error', eqeqeq: ['error', 'smart'], 'no-fallthrough': 'error', 'no-global-assign': 'error', @@ -111,6 +112,7 @@ module.exports = { ], 'no-return-await': 'error', 'no-self-assign': 'error', + 'no-self-compare': 'error', 'no-throw-literal': 'error', 'no-unused-labels': 'error', 'no-useless-call': 'error', @@ -180,6 +182,10 @@ module.exports = { /* eslint-disable max-len, quotes */ 'no-restricted-syntax': [ 'error', + { + selector: "CallExpression[callee.object.name='assert'][callee.property.name='doesNotThrow']", + message: "Please replace `assert.doesNotThrow()` and add a comment next to the code instead." + }, { selector: `CallExpression[callee.object.name='assert'][callee.property.name='throws'][arguments.1.type='Literal']:not([arguments.1.regex])`, message: 'use a regular expression for second argument of assert.throws()', @@ -204,6 +210,7 @@ module.exports = { /* eslint-enable max-len, quotes */ 'no-tabs': 'error', 'no-trailing-spaces': 'error', + 'no-unsafe-finally': 'error', 'object-curly-spacing': ['error', 'always'], 'one-var-declaration-per-line': 'error', 'operator-linebreak': ['error', 'after'], From acf2fd39f7461b36d895582e7b7d7a8b3be03eff Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 19 Feb 2018 17:36:59 +0800 Subject: [PATCH 28/47] test: introduce common.runWithInvalidFD() This provides a more reliable way to get a fd that can be used to tirgger EBADF. PR-URL: https://github.com/nodejs/node/pull/18864 Fixes: https://github.com/nodejs/node/issues/18820 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- test/common/README.md | 8 ++++++++ test/common/index.js | 13 +++++++++++++ 2 files changed, 21 insertions(+) diff --git a/test/common/README.md b/test/common/README.md index 01064a7a8b7..24468bdfd77 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -139,6 +139,14 @@ consisting of all `ArrayBufferView` and an `ArrayBuffer`. Returns the file name and line number for the provided Function. +### runWithInvalidFD(func) +* `func` [<Function>] + +Runs `func` with an invalid file descriptor that is an unsigned integer and +can be used to trigger `EBADF` as the first argument. If no such file +descriptor could be generated, a skip message will be printed and the `func` +will not be run. + ### globalCheck * [<boolean>] diff --git a/test/common/index.js b/test/common/index.js index 54b146814a4..10fd637af99 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -816,6 +816,19 @@ function restoreWritable(name) { delete process[name].writeTimes; } +exports.runWithInvalidFD = function(func) { + let fd = 1 << 30; + // Get first known bad file descriptor. 1 << 30 is usually unlikely to + // be an valid one. + try { + while (fs.fstatSync(fd--) && fd > 0); + } catch (e) { + return func(fd); + } + + exports.printSkipMessage('Could not generate an invalid fd'); +}; + exports.hijackStdout = hijackStdWritable.bind(null, 'stdout'); exports.hijackStderr = hijackStdWritable.bind(null, 'stderr'); exports.restoreStdout = restoreWritable.bind(null, 'stdout'); From 5055c29e82c4634e6845702fba97cc2438923d44 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 19 Feb 2018 17:38:11 +0800 Subject: [PATCH 29/47] test: use runWithInvalidFD() in tests expecting EBADF PR-URL: https://github.com/nodejs/node/pull/18864 Fixes: https://github.com/nodejs/node/issues/18820 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- test/parallel/test-fs-close-errors.js | 40 ------------ test/parallel/test-fs-error-messages.js | 83 ++++++++++++++---------- test/parallel/test-ttywrap-invalid-fd.js | 19 ++---- 3 files changed, 56 insertions(+), 86 deletions(-) diff --git a/test/parallel/test-fs-close-errors.js b/test/parallel/test-fs-close-errors.js index 4f0d31369a2..f81d96c0569 100644 --- a/test/parallel/test-fs-close-errors.js +++ b/test/parallel/test-fs-close-errors.js @@ -4,9 +4,7 @@ // include the desired properties const common = require('../common'); -const assert = require('assert'); const fs = require('fs'); -const uv = process.binding('uv'); ['', false, null, undefined, {}, []].forEach((i) => { common.expectsError( @@ -26,41 +24,3 @@ const uv = process.binding('uv'); } ); }); - -{ - assert.throws( - () => { - const fd = fs.openSync(__filename, 'r'); - fs.closeSync(fd); - fs.closeSync(fd); - }, - (err) => { - assert.strictEqual(err.code, 'EBADF'); - assert.strictEqual( - err.message, - 'EBADF: bad file descriptor, close' - ); - assert.strictEqual(err.constructor, Error); - assert.strictEqual(err.syscall, 'close'); - assert.strictEqual(err.errno, uv.UV_EBADF); - return true; - } - ); -} - -{ - const fd = fs.openSync(__filename, 'r'); - fs.close(fd, common.mustCall((err) => { - assert.ifError(err); - fs.close(fd, common.mustCall((err) => { - assert.strictEqual(err.code, 'EBADF'); - assert.strictEqual( - err.message, - 'EBADF: bad file descriptor, close' - ); - assert.strictEqual(err.constructor, Error); - assert.strictEqual(err.syscall, 'close'); - assert.strictEqual(err.errno, uv.UV_EBADF); - })); - })); -} diff --git a/test/parallel/test-fs-error-messages.js b/test/parallel/test-fs-error-messages.js index ba44c28d432..28461de9bee 100644 --- a/test/parallel/test-fs-error-messages.js +++ b/test/parallel/test-fs-error-messages.js @@ -94,15 +94,14 @@ function re(literals, ...values) { return true; }; - const fd = fs.openSync(existingFile, 'r'); - fs.closeSync(fd); - - fs.fstat(fd, common.mustCall(validateError)); - - assert.throws( - () => fs.fstatSync(fd), - validateError - ); + common.runWithInvalidFD((fd) => { + fs.fstat(fd, common.mustCall(validateError)); + + assert.throws( + () => fs.fstatSync(fd), + validateError + ); + }); } // realpath @@ -414,6 +413,27 @@ function re(literals, ...values) { ); } + +// close +{ + const validateError = (err) => { + assert.strictEqual(err.message, 'EBADF: bad file descriptor, close'); + assert.strictEqual(err.errno, uv.UV_EBADF); + assert.strictEqual(err.code, 'EBADF'); + assert.strictEqual(err.syscall, 'close'); + return true; + }; + + common.runWithInvalidFD((fd) => { + fs.close(fd, common.mustCall(validateError)); + + assert.throws( + () => fs.closeSync(fd), + validateError + ); + }); +} + // readFile { const validateError = (err) => { @@ -472,15 +492,14 @@ function re(literals, ...values) { return true; }; - const fd = fs.openSync(existingFile, 'r'); - fs.closeSync(fd); + common.runWithInvalidFD((fd) => { + fs.ftruncate(fd, 4, common.mustCall(validateError)); - fs.ftruncate(fd, 4, common.mustCall(validateError)); - - assert.throws( - () => fs.ftruncateSync(fd, 4), - validateError - ); + assert.throws( + () => fs.ftruncateSync(fd, 4), + validateError + ); + }); } // fdatasync @@ -493,15 +512,14 @@ function re(literals, ...values) { return true; }; - const fd = fs.openSync(existingFile, 'r'); - fs.closeSync(fd); - - fs.fdatasync(fd, common.mustCall(validateError)); + common.runWithInvalidFD((fd) => { + fs.fdatasync(fd, common.mustCall(validateError)); - assert.throws( - () => fs.fdatasyncSync(fd), - validateError - ); + assert.throws( + () => fs.fdatasyncSync(fd), + validateError + ); + }); } // fsync @@ -514,13 +532,12 @@ function re(literals, ...values) { return true; }; - const fd = fs.openSync(existingFile, 'r'); - fs.closeSync(fd); - - fs.fsync(fd, common.mustCall(validateError)); + common.runWithInvalidFD((fd) => { + fs.fsync(fd, common.mustCall(validateError)); - assert.throws( - () => fs.fsyncSync(fd), - validateError - ); + assert.throws( + () => fs.fsyncSync(fd), + validateError + ); + }); } diff --git a/test/parallel/test-ttywrap-invalid-fd.js b/test/parallel/test-ttywrap-invalid-fd.js index 6564d47fd93..adf88cbde65 100644 --- a/test/parallel/test-ttywrap-invalid-fd.js +++ b/test/parallel/test-ttywrap-invalid-fd.js @@ -2,7 +2,6 @@ // Flags: --expose-internals const common = require('../common'); -const fs = require('fs'); const tty = require('tty'); const { SystemError } = require('internal/errors'); @@ -22,12 +21,9 @@ common.expectsError( common.expectsError( () => { - let fd = 2; - // Get first known bad file descriptor. - try { - while (fs.fstatSync(++fd)); - } catch (e) { } - new tty.WriteStream(fd); + common.runWithInvalidFD((fd) => { + new tty.WriteStream(fd); + }); }, { code: 'ERR_SYSTEM_ERROR', type: SystemError, @@ -37,12 +33,9 @@ common.expectsError( common.expectsError( () => { - let fd = 2; - // Get first known bad file descriptor. - try { - while (fs.fstatSync(++fd)); - } catch (e) { } - new tty.ReadStream(fd); + common.runWithInvalidFD((fd) => { + new tty.ReadStream(fd); + }); }, { code: 'ERR_SYSTEM_ERROR', type: SystemError, From e5369e054bae809b73254f7ea93df02d7ac4eb8d Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Mon, 19 Feb 2018 14:43:02 +0100 Subject: [PATCH 30/47] http: allow _httpMessage to be GC'ed Set `socket._httpMessage` to `null` before emitting the `'connect'` or `'upgrade'` event. PR-URL: https://github.com/nodejs/node/pull/18865 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater Reviewed-By: Matteo Collina --- lib/_http_agent.js | 1 + test/parallel/test-http-connect.js | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 13abe9c210d..4d5fc7d2ede 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -277,6 +277,7 @@ function installListeners(agent, s, options) { s.removeListener('close', onClose); s.removeListener('free', onFree); s.removeListener('agentRemove', onRemove); + s._httpMessage = null; } s.on('agentRemove', onRemove); } diff --git a/test/parallel/test-http-connect.js b/test/parallel/test-http-connect.js index 06f855db9a0..30668ec9937 100644 --- a/test/parallel/test-http-connect.js +++ b/test/parallel/test-http-connect.js @@ -49,6 +49,10 @@ server.listen(0, common.mustCall(() => { path: 'google.com:443' }, common.mustNotCall()); + req.on('socket', common.mustCall((socket) => { + assert.strictEqual(socket._httpMessage, req); + })); + req.on('close', common.mustCall()); req.on('connect', common.mustCall((res, socket, firstBodyChunk) => { @@ -60,6 +64,7 @@ server.listen(0, common.mustCall(() => { // Make sure this socket has detached. assert(!socket.ondata); assert(!socket.onend); + assert.strictEqual(socket._httpMessage, null); assert.strictEqual(socket.listeners('connect').length, 0); assert.strictEqual(socket.listeners('data').length, 0); From 5782c51dfb729a1331e223e14ee3c9a5d0a19113 Mon Sep 17 00:00:00 2001 From: Trivikram <16024985+trivikr@users.noreply.github.com> Date: Sun, 18 Feb 2018 19:30:51 -0800 Subject: [PATCH 31/47] test: http2 stream.respond() error checks PR-URL: https://github.com/nodejs/node/pull/18861 Reviewed-By: James M Snell --- test/parallel/test-http2-respond-errors.js | 148 ++++++++---------- .../test-http2-respond-nghttperrors.js | 99 ++++++++++++ 2 files changed, 166 insertions(+), 81 deletions(-) create mode 100644 test/parallel/test-http2-respond-nghttperrors.js diff --git a/test/parallel/test-http2-respond-errors.js b/test/parallel/test-http2-respond-errors.js index 5ec953c5442..656a27df26e 100644 --- a/test/parallel/test-http2-respond-errors.js +++ b/test/parallel/test-http2-respond-errors.js @@ -5,95 +5,81 @@ const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); const http2 = require('http2'); -const { - constants, - Http2Stream, - nghttp2ErrorString -} = process.binding('http2'); -const { NghttpError } = require('internal/http2/util'); - -// tests error handling within respond -// - every other NGHTTP2 error from binding (should emit stream error) - -const specificTestKeys = []; - -const specificTests = []; - -const genericTests = Object.getOwnPropertyNames(constants) - .filter((key) => ( - key.indexOf('NGHTTP2_ERR') === 0 && specificTestKeys.indexOf(key) < 0 - )) - .map((key) => ({ - ngError: constants[key], - error: { - code: 'ERR_HTTP2_ERROR', - type: NghttpError, - name: 'Error [ERR_HTTP2_ERROR]', - message: nghttp2ErrorString(constants[key]) - }, - type: 'stream' - })); - - -const tests = specificTests.concat(genericTests); - -let currentError; - -// mock submitResponse because we only care about testing error handling -Http2Stream.prototype.respond = () => currentError.ngError; +const { Http2Stream } = process.binding('http2'); + +const types = { + boolean: true, + function: () => {}, + number: 1, + object: {}, + array: [], + null: null, + symbol: Symbol('test') +}; const server = http2.createServer(); -server.on('stream', common.mustCall((stream, headers) => { - const errorMustCall = common.expectsError(currentError.error); - const errorMustNotCall = common.mustNotCall( - `${currentError.error.code} should emit on ${currentError.type}` - ); - - if (currentError.type === 'stream') { - stream.session.on('error', errorMustNotCall); - stream.on('error', errorMustCall); - stream.on('error', common.mustCall(() => { - stream.destroy(); - })); - } else { - stream.session.once('error', errorMustCall); - stream.on('error', errorMustNotCall); - } - stream.respond(); -}, tests.length)); +Http2Stream.prototype.respond = () => 1; +server.on('stream', common.mustCall((stream) => { -server.listen(0, common.mustCall(() => runTest(tests.shift()))); + // Check for all possible TypeError triggers on options.getTrailers + Object.entries(types).forEach(([type, value]) => { + if (type === 'function') { + return; + } -function runTest(test) { - const port = server.address().port; - const url = `http://localhost:${port}`; - const headers = { - ':path': '/', - ':method': 'POST', - ':scheme': 'http', - ':authority': `localhost:${port}` - }; + common.expectsError( + () => stream.respond({ + 'content-type': 'text/plain' + }, { + ['getTrailers']: value + }), + { + type: TypeError, + code: 'ERR_INVALID_OPT_VALUE', + message: `The value "${String(value)}" is invalid ` + + 'for option "getTrailers"' + } + ); + }); + + // Send headers + stream.respond({ + 'content-type': 'text/plain' + }, { + ['getTrailers']: () => common.mustCall() + }); + + // Should throw if headers already sent + common.expectsError( + () => stream.respond(), + { + type: Error, + code: 'ERR_HTTP2_HEADERS_SENT', + message: 'Response has already been initiated.' + } + ); - const client = http2.connect(url); - const req = client.request(headers); - req.on('error', common.expectsError({ - code: 'ERR_HTTP2_STREAM_ERROR', - type: Error, - message: 'Stream closed with error code 2' - })); + // Should throw if stream already destroyed + stream.destroy(); + common.expectsError( + () => stream.respond(), + { + type: Error, + code: 'ERR_HTTP2_INVALID_STREAM', + message: 'The stream has been destroyed' + } + ); +})); - currentError = test; - req.resume(); - req.end(); +server.listen(0, common.mustCall(() => { + const client = http2.connect(`http://localhost:${server.address().port}`); + const req = client.request(); req.on('end', common.mustCall(() => { client.close(); - - if (!tests.length) { - server.close(); - } else { - runTest(tests.shift()); - } + server.close(); })); -} + req.resume(); + req.end(); +})); diff --git a/test/parallel/test-http2-respond-nghttperrors.js b/test/parallel/test-http2-respond-nghttperrors.js new file mode 100644 index 00000000000..5ec953c5442 --- /dev/null +++ b/test/parallel/test-http2-respond-nghttperrors.js @@ -0,0 +1,99 @@ +'use strict'; +// Flags: --expose-internals + +const common = require('../common'); +if (!common.hasCrypto) + common.skip('missing crypto'); +const http2 = require('http2'); +const { + constants, + Http2Stream, + nghttp2ErrorString +} = process.binding('http2'); +const { NghttpError } = require('internal/http2/util'); + +// tests error handling within respond +// - every other NGHTTP2 error from binding (should emit stream error) + +const specificTestKeys = []; + +const specificTests = []; + +const genericTests = Object.getOwnPropertyNames(constants) + .filter((key) => ( + key.indexOf('NGHTTP2_ERR') === 0 && specificTestKeys.indexOf(key) < 0 + )) + .map((key) => ({ + ngError: constants[key], + error: { + code: 'ERR_HTTP2_ERROR', + type: NghttpError, + name: 'Error [ERR_HTTP2_ERROR]', + message: nghttp2ErrorString(constants[key]) + }, + type: 'stream' + })); + + +const tests = specificTests.concat(genericTests); + +let currentError; + +// mock submitResponse because we only care about testing error handling +Http2Stream.prototype.respond = () => currentError.ngError; + +const server = http2.createServer(); +server.on('stream', common.mustCall((stream, headers) => { + const errorMustCall = common.expectsError(currentError.error); + const errorMustNotCall = common.mustNotCall( + `${currentError.error.code} should emit on ${currentError.type}` + ); + + if (currentError.type === 'stream') { + stream.session.on('error', errorMustNotCall); + stream.on('error', errorMustCall); + stream.on('error', common.mustCall(() => { + stream.destroy(); + })); + } else { + stream.session.once('error', errorMustCall); + stream.on('error', errorMustNotCall); + } + + stream.respond(); +}, tests.length)); + +server.listen(0, common.mustCall(() => runTest(tests.shift()))); + +function runTest(test) { + const port = server.address().port; + const url = `http://localhost:${port}`; + const headers = { + ':path': '/', + ':method': 'POST', + ':scheme': 'http', + ':authority': `localhost:${port}` + }; + + const client = http2.connect(url); + const req = client.request(headers); + req.on('error', common.expectsError({ + code: 'ERR_HTTP2_STREAM_ERROR', + type: Error, + message: 'Stream closed with error code 2' + })); + + currentError = test; + req.resume(); + req.end(); + + req.on('end', common.mustCall(() => { + client.close(); + + if (!tests.length) { + server.close(); + } else { + runTest(tests.shift()); + } + })); +} From a926c1a18f42ac8b9631838fb03980cbbded1bdf Mon Sep 17 00:00:00 2001 From: Trivikram <16024985+trivikr@users.noreply.github.com> Date: Sun, 18 Feb 2018 13:39:06 -0800 Subject: [PATCH 32/47] test: http2 compat response.write() error checks PR-URL: https://github.com/nodejs/node/pull/18859 Reviewed-By: James M Snell --- ...http2-compat-serverresponse-write-no-cb.js | 95 ------------------- .../test-http2-compat-serverresponse-write.js | 52 ++++++++++ 2 files changed, 52 insertions(+), 95 deletions(-) delete mode 100644 test/parallel/test-http2-compat-serverresponse-write-no-cb.js create mode 100644 test/parallel/test-http2-compat-serverresponse-write.js diff --git a/test/parallel/test-http2-compat-serverresponse-write-no-cb.js b/test/parallel/test-http2-compat-serverresponse-write-no-cb.js deleted file mode 100644 index a62bb1b0ac7..00000000000 --- a/test/parallel/test-http2-compat-serverresponse-write-no-cb.js +++ /dev/null @@ -1,95 +0,0 @@ -'use strict'; - -const { mustCall, - mustNotCall, - expectsError, - hasCrypto, skip } = require('../common'); -if (!hasCrypto) - skip('missing crypto'); -const { createServer, connect } = require('http2'); - -// Http2ServerResponse.write does not imply there is a callback - -{ - const server = createServer(); - server.listen(0, mustCall(() => { - const port = server.address().port; - const url = `http://localhost:${port}`; - const client = connect(url, mustCall(() => { - const request = client.request(); - request.resume(); - request.on('end', mustCall()); - request.on('close', mustCall(() => { - client.close(); - })); - })); - - server.once('request', mustCall((request, response) => { - client.destroy(); - response.stream.session.on('close', mustCall(() => { - response.on('error', mustNotCall()); - expectsError( - () => { response.write('muahaha'); }, - { - code: 'ERR_HTTP2_INVALID_STREAM' - } - ); - server.close(); - })); - })); - })); -} - -{ - const server = createServer(); - server.listen(0, mustCall(() => { - const port = server.address().port; - const url = `http://localhost:${port}`; - const client = connect(url, mustCall(() => { - const request = client.request(); - request.resume(); - request.on('end', mustCall()); - request.on('close', mustCall(() => client.close())); - })); - - server.once('request', mustCall((request, response) => { - client.destroy(); - response.stream.session.on('close', mustCall(() => { - expectsError( - () => response.write('muahaha'), - { - code: 'ERR_HTTP2_INVALID_STREAM' - } - ); - server.close(); - })); - })); - })); -} - -{ - const server = createServer(); - server.listen(0, mustCall(() => { - const port = server.address().port; - const url = `http://localhost:${port}`; - const client = connect(url, mustCall(() => { - const request = client.request(); - request.resume(); - request.on('end', mustCall()); - request.on('close', mustCall(() => client.close())); - })); - - server.once('request', mustCall((request, response) => { - response.stream.session.on('close', mustCall(() => { - expectsError( - () => response.write('muahaha', 'utf8'), - { - code: 'ERR_HTTP2_INVALID_STREAM' - } - ); - server.close(); - })); - client.destroy(); - })); - })); -} diff --git a/test/parallel/test-http2-compat-serverresponse-write.js b/test/parallel/test-http2-compat-serverresponse-write.js new file mode 100644 index 00000000000..af3029835ea --- /dev/null +++ b/test/parallel/test-http2-compat-serverresponse-write.js @@ -0,0 +1,52 @@ +'use strict'; + +const { + mustCall, + mustNotCall, + expectsError, + hasCrypto, + skip +} = require('../common'); +if (!hasCrypto) + skip('missing crypto'); +const { createServer, connect } = require('http2'); +const assert = require('assert'); + +const server = createServer(); +server.listen(0, mustCall(() => { + const port = server.address().port; + const url = `http://localhost:${port}`; + const client = connect(url, mustCall(() => { + const request = client.request(); + request.resume(); + request.on('end', mustCall()); + request.on('close', mustCall(() => { + client.close(); + })); + })); + + server.once('request', mustCall((request, response) => { + // response.write() returns true + assert(response.write('muahaha', 'utf8', mustCall())); + + response.stream.close(0, mustCall(() => { + response.on('error', mustNotCall()); + + // response.write() without cb returns error + expectsError( + () => { response.write('muahaha'); }, + { + type: Error, + code: 'ERR_HTTP2_INVALID_STREAM', + message: 'The stream has been destroyed' + } + ); + + // response.write() with cb returns falsy value + assert(!response.write('muahaha', mustCall())); + + client.destroy(); + server.close(); + })); + })); +})); From ff5b56ea9d70d24140bf4bc53b8692ef1513f43a Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 17 Feb 2018 03:45:07 +0100 Subject: [PATCH 33/47] tools: enable eslint no-undef-init rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also fixes the three entries that did not pass. PR-URL: https://github.com/nodejs/node/pull/18831 Reviewed-By: Luigi Pinca Reviewed-By: Matheus Marchini Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso Reviewed-By: Anatoli Papirovski Reviewed-By: Colin Ihrig --- .eslintrc.js | 1 + lib/internal/util.js | 4 ++-- test/parallel/test-fs-utimes.js | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index cd5fc51e8e3..58f131c1b6f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -130,6 +130,7 @@ module.exports = { // http://eslint.org/docs/rules/#variables 'no-delete-var': 'error', 'no-undef': 'error', + 'no-undef-init': 'error', 'no-unused-vars': ['error', { args: 'none' }], 'no-use-before-define': ['error', { classes: true, diff --git a/lib/internal/util.js b/lib/internal/util.js index 630cd0ef213..5cec64ca18b 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -228,8 +228,8 @@ function getSystemErrorName(err) { // getConstructorOf is wrapped into this to save iterations function getIdentificationOf(obj) { const original = obj; - let constructor = undefined; - let tag = undefined; + let constructor; + let tag; while (obj) { if (constructor === undefined) { diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js index dae9c7dc9ea..5b57287a642 100644 --- a/test/parallel/test-fs-utimes.js +++ b/test/parallel/test-fs-utimes.js @@ -88,7 +88,7 @@ function testIt(atime, mtime, callback) { expect_errno('futimesSync', fd, ex, 'ENOSYS'); } - let err = undefined; + let err; try { fs.utimesSync('foobarbaz', atime, mtime); } catch (ex) { From 684c1bb42d916fed12945ba1678934e8983082dd Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 17 Feb 2018 03:46:15 +0100 Subject: [PATCH 34/47] tools: enable eslint strict key-spacing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/18831 Reviewed-By: Luigi Pinca Reviewed-By: Matheus Marchini Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso Reviewed-By: Anatoli Papirovski Reviewed-By: Colin Ihrig --- .eslintrc.js | 2 +- benchmark/http/_chunky_http_client.js | 4 ++-- test/parallel/test-eslint-require-buffer.js | 8 ++++---- test/parallel/test-https-agent-servername.js | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 58f131c1b6f..e72726197a2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -166,7 +166,7 @@ module.exports = { ObjectExpression: 'first', SwitchCase: 1, }], - 'key-spacing': ['error', { mode: 'minimum' }], + 'key-spacing': ['error', { mode: 'strict' }], 'keyword-spacing': 'error', 'linebreak-style': ['error', 'unix'], 'max-len': ['error', { diff --git a/benchmark/http/_chunky_http_client.js b/benchmark/http/_chunky_http_client.js index a90535e489f..7728a5d06c6 100644 --- a/benchmark/http/_chunky_http_client.js +++ b/benchmark/http/_chunky_http_client.js @@ -5,8 +5,8 @@ const common = require('../common.js'); const net = require('net'); const bench = common.createBenchmark(main, { - len: [1, 4, 8, 16, 32, 64, 128], - n: [5, 50, 500, 2000], + len: [1, 4, 8, 16, 32, 64, 128], + n: [5, 50, 500, 2000], type: ['send'], }); diff --git a/test/parallel/test-eslint-require-buffer.js b/test/parallel/test-eslint-require-buffer.js index ca2c44cb322..bdc794dd594 100644 --- a/test/parallel/test-eslint-require-buffer.js +++ b/test/parallel/test-eslint-require-buffer.js @@ -36,14 +36,14 @@ ruleTester.run('require-buffer', rule, { output: useStrict + bufferModule + useBuffer, }, { - code: mockComment + useBuffer, + code: mockComment + useBuffer, errors: [{ message }], - output: mockComment + bufferModule + useBuffer, + output: mockComment + bufferModule + useBuffer, }, { - code: mockComment + useStrict + useBuffer, + code: mockComment + useStrict + useBuffer, errors: [{ message }], - output: mockComment + useStrict + bufferModule + useBuffer, + output: mockComment + useStrict + bufferModule + useBuffer, }, ] }); diff --git a/test/parallel/test-https-agent-servername.js b/test/parallel/test-https-agent-servername.js index 985fbb3ce3f..df14d113994 100644 --- a/test/parallel/test-https-agent-servername.js +++ b/test/parallel/test-https-agent-servername.js @@ -10,7 +10,7 @@ const fixtures = require('../common/fixtures'); const options = { key: fixtures.readKey('agent1-key.pem'), cert: fixtures.readKey('agent1-cert.pem'), - ca: fixtures.readKey('ca1-cert.pem') + ca: fixtures.readKey('ca1-cert.pem') }; From cbc6f39b718513282cfd841dcc90a9df3f547de9 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 17 Feb 2018 03:49:26 +0100 Subject: [PATCH 35/47] tools: enable eslint no-whitespace-before-property rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/18831 Reviewed-By: Luigi Pinca Reviewed-By: Matheus Marchini Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso Reviewed-By: Anatoli Papirovski Reviewed-By: Colin Ihrig --- .eslintrc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintrc.js b/.eslintrc.js index e72726197a2..a4439d7ab23 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -212,6 +212,7 @@ module.exports = { 'no-tabs': 'error', 'no-trailing-spaces': 'error', 'no-unsafe-finally': 'error', + 'no-whitespace-before-property': 'error', 'object-curly-spacing': ['error', 'always'], 'one-var-declaration-per-line': 'error', 'operator-linebreak': ['error', 'after'], From 8be96579aeee39e3942bde7f1bb56b21bd9a99e9 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 17 Feb 2018 03:51:11 +0100 Subject: [PATCH 36/47] tools: enable eslint one-var rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/18831 Reviewed-By: Luigi Pinca Reviewed-By: Matheus Marchini Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso Reviewed-By: Anatoli Papirovski Reviewed-By: Colin Ihrig --- .eslintrc.js | 1 + benchmark/tls/tls-connect.js | 6 +-- test/parallel/test-cluster-worker-kill.js | 45 +++++++++++------------ 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index a4439d7ab23..5ea4d0b086b 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -214,6 +214,7 @@ module.exports = { 'no-unsafe-finally': 'error', 'no-whitespace-before-property': 'error', 'object-curly-spacing': ['error', 'always'], + 'one-var': ['error', { initialized: 'never' }], 'one-var-declaration-per-line': 'error', 'operator-linebreak': ['error', 'after'], quotes: ['error', 'single', 'avoid-escape'], diff --git a/benchmark/tls/tls-connect.js b/benchmark/tls/tls-connect.js index da0f5e08d5e..524d7468d00 100644 --- a/benchmark/tls/tls-connect.js +++ b/benchmark/tls/tls-connect.js @@ -1,7 +1,7 @@ 'use strict'; -var fs = require('fs'), - path = require('path'), - tls = require('tls'); +const fs = require('fs'); +const path = require('path'); +const tls = require('tls'); const common = require('../common.js'); const bench = common.createBenchmark(main, { diff --git a/test/parallel/test-cluster-worker-kill.js b/test/parallel/test-cluster-worker-kill.js index 38e2deb1555..bb2d3495d95 100644 --- a/test/parallel/test-cluster-worker-kill.js +++ b/test/parallel/test-cluster-worker-kill.js @@ -40,29 +40,28 @@ if (cluster.isWorker) { } else if (cluster.isMaster) { - const KILL_SIGNAL = 'SIGKILL', - expected_results = { - cluster_emitDisconnect: [1, "the cluster did not emit 'disconnect'"], - cluster_emitExit: [1, "the cluster did not emit 'exit'"], - cluster_exitCode: [null, 'the cluster exited w/ incorrect exitCode'], - cluster_signalCode: [KILL_SIGNAL, - 'the cluster exited w/ incorrect signalCode'], - worker_emitDisconnect: [1, "the worker did not emit 'disconnect'"], - worker_emitExit: [1, "the worker did not emit 'exit'"], - worker_state: ['disconnected', 'the worker state is incorrect'], - worker_exitedAfter: [false, - 'the .exitedAfterDisconnect flag is incorrect'], - worker_died: [true, 'the worker is still running'], - worker_exitCode: [null, 'the worker exited w/ incorrect exitCode'], - worker_signalCode: [KILL_SIGNAL, - 'the worker exited w/ incorrect signalCode'] - }, - results = { - cluster_emitDisconnect: 0, - cluster_emitExit: 0, - worker_emitDisconnect: 0, - worker_emitExit: 0 - }; + const KILL_SIGNAL = 'SIGKILL'; + const expected_results = { + cluster_emitDisconnect: [1, "the cluster did not emit 'disconnect'"], + cluster_emitExit: [1, "the cluster did not emit 'exit'"], + cluster_exitCode: [null, 'the cluster exited w/ incorrect exitCode'], + cluster_signalCode: [KILL_SIGNAL, + 'the cluster exited w/ incorrect signalCode'], + worker_emitDisconnect: [1, "the worker did not emit 'disconnect'"], + worker_emitExit: [1, "the worker did not emit 'exit'"], + worker_state: ['disconnected', 'the worker state is incorrect'], + worker_exitedAfter: [false, 'the .exitedAfterDisconnect flag is incorrect'], + worker_died: [true, 'the worker is still running'], + worker_exitCode: [null, 'the worker exited w/ incorrect exitCode'], + worker_signalCode: [KILL_SIGNAL, + 'the worker exited w/ incorrect signalCode'] + }; + const results = { + cluster_emitDisconnect: 0, + cluster_emitExit: 0, + worker_emitDisconnect: 0, + worker_emitExit: 0 + }; // start worker From 3a2e912b2d75730a7733200c953b59b98793ae81 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 17 Feb 2018 03:51:36 +0100 Subject: [PATCH 37/47] tools: update eslint rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The former notation was deprecated. This updates it as recommended. PR-URL: https://github.com/nodejs/node/pull/18831 Reviewed-By: Luigi Pinca Reviewed-By: Matheus Marchini Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso Reviewed-By: Anatoli Papirovski Reviewed-By: Colin Ihrig --- .eslintrc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.eslintrc.js b/.eslintrc.js index 5ea4d0b086b..5fb535c3d83 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -217,7 +217,7 @@ module.exports = { 'one-var': ['error', { initialized: 'never' }], 'one-var-declaration-per-line': 'error', 'operator-linebreak': ['error', 'after'], - quotes: ['error', 'single', 'avoid-escape'], + quotes: ['error', 'single', { avoidEscape: true }], semi: 'error', 'semi-spacing': 'error', 'space-before-blocks': ['error', 'always'], From d6fc7e3af4f8888b0d80d73287314b14d3c7f86e Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Sat, 17 Feb 2018 03:58:50 +0100 Subject: [PATCH 38/47] doc: enable eslint prefer-template rule MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/18831 Reviewed-By: Luigi Pinca Reviewed-By: Matheus Marchini Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso Reviewed-By: Anatoli Papirovski Reviewed-By: Colin Ihrig --- doc/.eslintrc.yaml | 1 + doc/api/esm.md | 4 ++-- doc/api/http.md | 2 +- doc/api/stream.md | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/.eslintrc.yaml b/doc/.eslintrc.yaml index c8c1612e3a1..7b38afec102 100644 --- a/doc/.eslintrc.yaml +++ b/doc/.eslintrc.yaml @@ -12,6 +12,7 @@ rules: no-var: error prefer-const: error prefer-rest-params: error + prefer-template: error # Stylistic Issues no-multiple-empty-lines: [error, {max: 1, maxEOF: 0, maxBOF: 0}] diff --git a/doc/api/esm.md b/doc/api/esm.md index 3ff2904488a..2a564332951 100644 --- a/doc/api/esm.md +++ b/doc/api/esm.md @@ -118,7 +118,7 @@ given module specifier and parent file URL: ```js const baseURL = new URL('file://'); -baseURL.pathname = process.cwd() + '/'; +baseURL.pathname = `${process.cwd()}/`; export async function resolve(specifier, parentModuleURL = baseURL, @@ -161,7 +161,7 @@ const builtins = Module.builtinModules; const JS_EXTENSIONS = new Set(['.js', '.mjs']); const baseURL = new URL('file://'); -baseURL.pathname = process.cwd() + '/'; +baseURL.pathname = `${process.cwd()}/`; export function resolve(specifier, parentModuleURL = baseURL, defaultResolve) { if (builtins.includes(specifier)) { diff --git a/doc/api/http.md b/doc/api/http.md index daa058a8b0b..e396471b3e9 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -422,7 +422,7 @@ const req = http.request(options); req.end(); req.on('information', (res) => { - console.log('got information prior to main response: ' + res.statusCode); + console.log(`Got information prior to main response: ${res.statusCode}`); }); ``` diff --git a/doc/api/stream.md b/doc/api/stream.md index c72873c466f..20eaa95bc19 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1852,7 +1852,7 @@ class Counter extends Readable { if (i > this._max) this.push(null); else { - const str = '' + i; + const str = String(i); const buf = Buffer.from(str, 'ascii'); this.push(buf); } From 51be03cd577fe8b5a73dd9558bd6a2727f9c3c0b Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Mon, 19 Feb 2018 17:54:08 +0100 Subject: [PATCH 39/47] http: remove default 'error' listener on upgrade Remove the default `'error'` listener when the socket is freed. This is consistent with the client and prevents spurious `'clientError'` events from being emitted on the server. PR-URL: https://github.com/nodejs/node/pull/18868 Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Ruben Bridgewater Reviewed-By: Joyee Cheung --- lib/_http_server.js | 1 + test/parallel/test-http-connect.js | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/lib/_http_server.js b/lib/_http_server.js index 1d093bab8bd..e83eeae8585 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -521,6 +521,7 @@ function onParserExecuteCommon(server, socket, parser, state, ret, d) { socket.removeListener('close', state.onClose); socket.removeListener('drain', state.onDrain); socket.removeListener('drain', ondrain); + socket.removeListener('error', socketOnError); unconsume(parser, socket); parser.finish(); freeParser(parser, req, null); diff --git a/test/parallel/test-http-connect.js b/test/parallel/test-http-connect.js index 30668ec9937..e7fb116de93 100644 --- a/test/parallel/test-http-connect.js +++ b/test/parallel/test-http-connect.js @@ -30,6 +30,13 @@ server.on('connect', common.mustCall((req, socket, firstBodyChunk) => { assert.strictEqual(req.method, 'CONNECT'); assert.strictEqual(req.url, 'google.com:443'); + // Make sure this socket has detached. + assert.strictEqual(socket.listeners('close').length, 0); + assert.strictEqual(socket.listeners('drain').length, 0); + assert.strictEqual(socket.listeners('data').length, 0); + assert.strictEqual(socket.listeners('end').length, 1); + assert.strictEqual(socket.listeners('error').length, 0); + socket.write('HTTP/1.1 200 Connection established\r\n\r\n'); let data = firstBodyChunk.toString(); From 26231548ad1dff971cdeaab3085b372a75ad1efb Mon Sep 17 00:00:00 2001 From: killagu Date: Tue, 20 Feb 2018 20:12:58 +0800 Subject: [PATCH 40/47] repl: fix tab-complete warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When create a nest repl, will register `Runtime.executionContextCreated` listener to the inspector session.This patch will fix listener repeatedly register. PR-URL: https://github.com/nodejs/node/pull/18881 Fixes: https://github.com/nodejs/node/issues/18284 Reviewed-By: Michaël Zasso Reviewed-By: Anna Henningsen Reviewed-By: Benjamin Gruenbaum Reviewed-By: Colin Ihrig Reviewed-By: Ruben Bridgewater --- lib/repl.js | 3 +-- .../test-repl-tab-complete-no-warn.js | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-repl-tab-complete-no-warn.js diff --git a/lib/repl.js b/lib/repl.js index bd41ecdccf6..8201630c3a6 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -753,7 +753,7 @@ REPLServer.prototype.createContext = function() { } else { sendInspectorCommand((session) => { session.post('Runtime.enable'); - session.on('Runtime.executionContextCreated', ({ params }) => { + session.once('Runtime.executionContextCreated', ({ params }) => { this[kContextId] = params.context.id; }); context = vm.createContext(); @@ -937,7 +937,6 @@ function complete(line, callback) { var flat = new ArrayStream(); // make a new "input" stream var magic = new REPLServer('', flat); // make a nested REPL replMap.set(magic, replMap.get(this)); - magic.resetContext(); flat.run(tmp); // eval the flattened code // all this is only profitable if the nested REPL // does not have a bufferedCommand diff --git a/test/parallel/test-repl-tab-complete-no-warn.js b/test/parallel/test-repl-tab-complete-no-warn.js new file mode 100644 index 00000000000..3379cec8453 --- /dev/null +++ b/test/parallel/test-repl-tab-complete-no-warn.js @@ -0,0 +1,22 @@ +'use strict'; + +const common = require('../common'); +const repl = require('repl'); +const DEFAULT_MAX_LISTENERS = require('events').defaultMaxListeners; + +common.ArrayStream.prototype.write = () => { +}; + +const putIn = new common.ArrayStream(); +const testMe = repl.start('', putIn); + +// https://github.com/nodejs/node/issues/18284 +// Tab-completion should not repeatedly add the +// `Runtime.executionContextCreated` listener +process.on('warning', common.mustNotCall()); + +putIn.run(['.clear']); +putIn.run(['async function test() {']); +for (let i = 0; i < DEFAULT_MAX_LISTENERS; i++) { + testMe.complete('await Promise.resolve()', () => {}); +} From 13cb056e4cfce7419148eb089205735fb12bcd9f Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 21 Feb 2018 14:53:53 +0100 Subject: [PATCH 41/47] deps: cherry-pick 46c4979e86 from upstream v8 Original commit message: Use wider types for max_old_space_size and co. Make --max_old_space_size and friends work with values >= 2**31. Such values did not work reliably (or sometimes not all) due to signed integer overflow in size computations, which is UB. Fixes https://github.com/nodejs/node/issues/18786. Bug: chromium:814138 Cq-Include-Trybots: master.tryserver.chromium.linux:linux_chromium_rel_ng Change-Id: Ibe23cef2417fd5b4a727022b8b0d4b50f1417182 Reviewed-on: https://chromium-review.googlesource.com/927063 Commit-Queue: Ben Noordhuis Reviewed-by: Michael Lippautz Cr-Commit-Position: refs/heads/master@{#51433} PR-URL: https://github.com/nodejs/node/pull/18920 Fixes: https://github.com/nodejs/node/issues/18786 Reviewed-By: Yang Guo Reviewed-By: Ruben Bridgewater --- common.gypi | 2 +- deps/v8/src/api.cc | 7 ++-- deps/v8/src/flag-definitions.h | 18 +++++---- deps/v8/src/flags.cc | 67 ++++++++++++++++++++++++++-------- deps/v8/src/heap/heap.cc | 4 +- deps/v8/src/heap/heap.h | 26 ++++++------- 6 files changed, 82 insertions(+), 42 deletions(-) diff --git a/common.gypi b/common.gypi index f6002f93491..a3aeff7e03d 100644 --- a/common.gypi +++ b/common.gypi @@ -27,7 +27,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.3', + 'v8_embedder_string': '-node.4', # Enable disassembler for `--print-code` v8 options 'v8_enable_disassembler': 1, diff --git a/deps/v8/src/api.cc b/deps/v8/src/api.cc index 53969b2b554..856be6368ba 100644 --- a/deps/v8/src/api.cc +++ b/deps/v8/src/api.cc @@ -911,8 +911,7 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, uint64_t virtual_memory_limit) { set_max_semi_space_size_in_kb( i::Heap::ComputeMaxSemiSpaceSize(physical_memory)); - set_max_old_space_size( - static_cast(i::Heap::ComputeMaxOldGenerationSize(physical_memory))); + set_max_old_space_size(i::Heap::ComputeMaxOldGenerationSize(physical_memory)); set_max_zone_pool_size(i::AccountingAllocator::kMaxPoolSize); if (virtual_memory_limit > 0 && i::kRequiresCodeRange) { @@ -927,7 +926,9 @@ void ResourceConstraints::ConfigureDefaults(uint64_t physical_memory, void SetResourceConstraints(i::Isolate* isolate, const ResourceConstraints& constraints) { size_t semi_space_size = constraints.max_semi_space_size_in_kb(); - int old_space_size = constraints.max_old_space_size(); + size_t old_space_size = + static_cast( + static_cast(constraints.max_old_space_size())); size_t code_range_size = constraints.code_range_size(); size_t max_pool_size = constraints.max_zone_pool_size(); if (semi_space_size != 0 || old_space_size != 0 || code_range_size != 0) { diff --git a/deps/v8/src/flag-definitions.h b/deps/v8/src/flag-definitions.h index 4ea5ed6da06..d81ececa2ae 100644 --- a/deps/v8/src/flag-definitions.h +++ b/deps/v8/src/flag-definitions.h @@ -161,6 +161,7 @@ struct MaybeBoolFlag { #define DEFINE_INT(nam, def, cmt) FLAG(INT, int, nam, def, cmt) #define DEFINE_UINT(nam, def, cmt) FLAG(UINT, unsigned int, nam, def, cmt) #define DEFINE_FLOAT(nam, def, cmt) FLAG(FLOAT, double, nam, def, cmt) +#define DEFINE_SIZE_T(nam, def, cmt) FLAG(SIZE_T, size_t, nam, def, cmt) #define DEFINE_STRING(nam, def, cmt) FLAG(STRING, const char*, nam, def, cmt) #define DEFINE_ARGS(nam, cmt) \ FLAG(ARGS, JSArguments, nam, {0 COMMA nullptr}, cmt) @@ -168,6 +169,7 @@ struct MaybeBoolFlag { #define DEFINE_ALIAS_BOOL(alias, nam) FLAG_ALIAS(BOOL, bool, alias, nam) #define DEFINE_ALIAS_INT(alias, nam) FLAG_ALIAS(INT, int, alias, nam) #define DEFINE_ALIAS_FLOAT(alias, nam) FLAG_ALIAS(FLOAT, double, alias, nam) +#define DEFINE_ALIAS_SIZE_T(alias, nam) FLAG_ALIAS(SIZE_T, size_t, alias, nam) #define DEFINE_ALIAS_STRING(alias, nam) \ FLAG_ALIAS(STRING, const char*, alias, nam) #define DEFINE_ALIAS_ARGS(alias, nam) FLAG_ALIAS(ARGS, JSArguments, alias, nam) @@ -580,18 +582,18 @@ DEFINE_INT(generic_ic_threshold, 30, DEFINE_INT(self_opt_count, 130, "call count before self-optimization") // Garbage collections flags. -DEFINE_INT(min_semi_space_size, 0, - "min size of a semi-space (in MBytes), the new space consists of two" - "semi-spaces") -DEFINE_INT(max_semi_space_size, 0, - "max size of a semi-space (in MBytes), the new space consists of two" - "semi-spaces") +DEFINE_SIZE_T(min_semi_space_size, 0, + "min size of a semi-space (in MBytes), the new space consists of " + "two semi-spaces") +DEFINE_SIZE_T(max_semi_space_size, 0, + "max size of a semi-space (in MBytes), the new space consists of " + "two semi-spaces") DEFINE_INT(semi_space_growth_factor, 2, "factor by which to grow the new space") DEFINE_BOOL(experimental_new_space_growth_heuristic, false, "Grow the new space based on the percentage of survivors instead " "of their absolute value.") -DEFINE_INT(max_old_space_size, 0, "max size of the old space (in Mbytes)") -DEFINE_INT(initial_old_space_size, 0, "initial old space size (in Mbytes)") +DEFINE_SIZE_T(max_old_space_size, 0, "max size of the old space (in Mbytes)") +DEFINE_SIZE_T(initial_old_space_size, 0, "initial old space size (in Mbytes)") DEFINE_BOOL(gc_global, false, "always perform global GCs") DEFINE_INT(gc_interval, -1, "garbage collect after allocations") DEFINE_INT(retain_maps_for_n_gc, 2, diff --git a/deps/v8/src/flags.cc b/deps/v8/src/flags.cc index a1df0e09570..a51a4e7d71e 100644 --- a/deps/v8/src/flags.cc +++ b/deps/v8/src/flags.cc @@ -5,6 +5,7 @@ #include "src/flags.h" #include +#include #include #include @@ -39,6 +40,7 @@ struct Flag { TYPE_INT, TYPE_UINT, TYPE_FLOAT, + TYPE_SIZE_T, TYPE_STRING, TYPE_ARGS }; @@ -81,6 +83,11 @@ struct Flag { return reinterpret_cast(valptr_); } + size_t* size_t_variable() const { + DCHECK(type_ == TYPE_SIZE_T); + return reinterpret_cast(valptr_); + } + const char* string_value() const { DCHECK(type_ == TYPE_STRING); return *reinterpret_cast(valptr_); @@ -119,6 +126,11 @@ struct Flag { return *reinterpret_cast(defptr_); } + size_t size_t_default() const { + DCHECK(type_ == TYPE_SIZE_T); + return *reinterpret_cast(defptr_); + } + const char* string_default() const { DCHECK(type_ == TYPE_STRING); return *reinterpret_cast(defptr_); @@ -142,6 +154,8 @@ struct Flag { return *uint_variable() == uint_default(); case TYPE_FLOAT: return *float_variable() == float_default(); + case TYPE_SIZE_T: + return *size_t_variable() == size_t_default(); case TYPE_STRING: { const char* str1 = string_value(); const char* str2 = string_default(); @@ -173,6 +187,9 @@ struct Flag { case TYPE_FLOAT: *float_variable() = float_default(); break; + case TYPE_SIZE_T: + *size_t_variable() = size_t_default(); + break; case TYPE_STRING: set_string_value(string_default(), false); break; @@ -201,6 +218,8 @@ static const char* Type2String(Flag::FlagType type) { case Flag::TYPE_UINT: return "uint"; case Flag::TYPE_FLOAT: return "float"; + case Flag::TYPE_SIZE_T: + return "size_t"; case Flag::TYPE_STRING: return "string"; case Flag::TYPE_ARGS: return "arguments"; } @@ -227,6 +246,9 @@ std::ostream& operator<<(std::ostream& os, const Flag& flag) { // NOLINT case Flag::TYPE_FLOAT: os << *flag.float_variable(); break; + case Flag::TYPE_SIZE_T: + os << *flag.size_t_variable(); + break; case Flag::TYPE_STRING: { const char* str = flag.string_value(); os << (str ? str : "nullptr"); @@ -358,6 +380,27 @@ static Flag* FindFlag(const char* name) { return nullptr; } +template +bool TryParseUnsigned(Flag* flag, const char* arg, const char* value, + char** endp, T* out_val) { + // We do not use strtoul because it accepts negative numbers. + // Rejects values >= 2**63 when T is 64 bits wide but that + // seems like an acceptable trade-off. + uint64_t max = static_cast(std::numeric_limits::max()); + errno = 0; + int64_t val = static_cast(strtoll(value, endp, 10)); + if (val < 0 || static_cast(val) > max || errno != 0) { + PrintF(stderr, + "Error: Value for flag %s of type %s is out of bounds " + "[0-%" PRIu64 + "]\n" + "Try --help for options\n", + arg, Type2String(flag->type()), max); + return false; + } + *out_val = static_cast(val); + return true; +} // static int FlagList::SetFlagsFromCommandLine(int* argc, @@ -422,27 +465,21 @@ int FlagList::SetFlagsFromCommandLine(int* argc, case Flag::TYPE_INT: *flag->int_variable() = static_cast(strtol(value, &endp, 10)); break; - case Flag::TYPE_UINT: { - // We do not use strtoul because it accepts negative numbers. - int64_t val = static_cast(strtoll(value, &endp, 10)); - if (val < 0 || val > std::numeric_limits::max()) { - PrintF(stderr, - "Error: Value for flag %s of type %s is out of bounds " - "[0-%" PRIu64 - "]\n" - "Try --help for options\n", - arg, Type2String(flag->type()), - static_cast( - std::numeric_limits::max())); + case Flag::TYPE_UINT: + if (!TryParseUnsigned(flag, arg, value, &endp, + flag->uint_variable())) { return_code = j; - break; } - *flag->uint_variable() = static_cast(val); break; - } case Flag::TYPE_FLOAT: *flag->float_variable() = strtod(value, &endp); break; + case Flag::TYPE_SIZE_T: + if (!TryParseUnsigned(flag, arg, value, &endp, + flag->size_t_variable())) { + return_code = j; + } + break; case Flag::TYPE_STRING: flag->set_string_value(value ? StrDup(value) : nullptr, true); break; diff --git a/deps/v8/src/heap/heap.cc b/deps/v8/src/heap/heap.cc index d90f086be4d..5aed1179036 100644 --- a/deps/v8/src/heap/heap.cc +++ b/deps/v8/src/heap/heap.cc @@ -5095,8 +5095,8 @@ bool Heap::ConfigureHeap(size_t max_semi_space_size_in_kb, // The new space size must be a power of two to support single-bit testing // for containment. - max_semi_space_size_ = base::bits::RoundUpToPowerOfTwo32( - static_cast(max_semi_space_size_)); + max_semi_space_size_ = static_cast(base::bits::RoundUpToPowerOfTwo64( + static_cast(max_semi_space_size_))); if (max_semi_space_size_ == kMaxSemiSpaceSizeInKB * KB) { // Start with at least 1*MB semi-space on machines with a lot of memory. diff --git a/deps/v8/src/heap/heap.h b/deps/v8/src/heap/heap.h index 7048d01e25d..72d74c9715a 100644 --- a/deps/v8/src/heap/heap.h +++ b/deps/v8/src/heap/heap.h @@ -626,15 +626,15 @@ class Heap { #endif // Semi-space size needs to be a multiple of page size. - static const int kMinSemiSpaceSizeInKB = + static const size_t kMinSemiSpaceSizeInKB = 1 * kPointerMultiplier * ((1 << kPageSizeBits) / KB); - static const int kMaxSemiSpaceSizeInKB = + static const size_t kMaxSemiSpaceSizeInKB = 16 * kPointerMultiplier * ((1 << kPageSizeBits) / KB); // The old space size has to be a multiple of Page::kPageSize. // Sizes are in MB. - static const int kMinOldGenerationSize = 128 * kPointerMultiplier; - static const int kMaxOldGenerationSize = 1024 * kPointerMultiplier; + static const size_t kMinOldGenerationSize = 128 * kPointerMultiplier; + static const size_t kMaxOldGenerationSize = 1024 * kPointerMultiplier; static const int kTraceRingBufferSize = 512; static const int kStacktraceBufferSize = 512; @@ -1372,10 +1372,10 @@ class Heap { size_t MaxOldGenerationSize() { return max_old_generation_size_; } static size_t ComputeMaxOldGenerationSize(uint64_t physical_memory) { - const int old_space_physical_memory_factor = 4; - int computed_size = - static_cast(physical_memory / i::MB / - old_space_physical_memory_factor * kPointerMultiplier); + const size_t old_space_physical_memory_factor = 4; + size_t computed_size = static_cast( + physical_memory / i::MB / old_space_physical_memory_factor * + kPointerMultiplier); return Max(Min(computed_size, kMaxOldGenerationSize), kMinOldGenerationSize); } @@ -1387,11 +1387,11 @@ class Heap { uint64_t capped_physical_memory = Max(Min(physical_memory, max_physical_memory), min_physical_memory); // linearly scale max semi-space size: (X-A)/(B-A)*(D-C)+C - int semi_space_size_in_kb = - static_cast(((capped_physical_memory - min_physical_memory) * - (kMaxSemiSpaceSizeInKB - kMinSemiSpaceSizeInKB)) / - (max_physical_memory - min_physical_memory) + - kMinSemiSpaceSizeInKB); + size_t semi_space_size_in_kb = + static_cast(((capped_physical_memory - min_physical_memory) * + (kMaxSemiSpaceSizeInKB - kMinSemiSpaceSizeInKB)) / + (max_physical_memory - min_physical_memory) + + kMinSemiSpaceSizeInKB); return RoundUp(semi_space_size_in_kb, (1 << kPageSizeBits) / KB); } From 070a82e82c917492bf306e546cef55ffb3ca8359 Mon Sep 17 00:00:00 2001 From: Sergey Golovin Date: Mon, 19 Feb 2018 21:13:54 +0300 Subject: [PATCH 42/47] module: replace "magic" numbers by constants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - add new constants - replace numbers by constants PR-URL: https://github.com/nodejs/node/pull/18869 Reviewed-By: Colin Ihrig Reviewed-By: Michaël Zasso Reviewed-By: Ruben Bridgewater Reviewed-By: Matheus Marchini --- lib/internal/constants.js | 4 ++++ lib/internal/module.js | 13 ++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/internal/constants.js b/lib/internal/constants.js index d059dbc7ef8..93bf926a84e 100644 --- a/lib/internal/constants.js +++ b/lib/internal/constants.js @@ -14,6 +14,10 @@ module.exports = { CHAR_COLON: 58, /* : */ CHAR_QUESTION_MARK: 63, /* ? */ CHAR_UNDERSCORE: 95, /* _ */ + CHAR_LINE_FEED: 10, /* \n */ + CHAR_CARRIAGE_RETURN: 13, /* \r */ + CHAR_EXCLAMATION_MARK: 33, /* ! */ + CHAR_HASH: 35, /* # */ // Digits CHAR_0: 48, /* 0 */ diff --git a/lib/internal/module.js b/lib/internal/module.js index c3dede40fa3..6e2fb15268f 100644 --- a/lib/internal/module.js +++ b/lib/internal/module.js @@ -2,6 +2,13 @@ const errors = require('internal/errors'); +const { + CHAR_LINE_FEED, + CHAR_CARRIAGE_RETURN, + CHAR_EXCLAMATION_MARK, + CHAR_HASH, +} = require('internal/constants'); + // Invoke with makeRequireFunction(module) where |module| is the Module object // to use as the context for the require() function. function makeRequireFunction(mod) { @@ -65,8 +72,8 @@ function stripShebang(content) { // Remove shebang var contLen = content.length; if (contLen >= 2) { - if (content.charCodeAt(0) === 35/*#*/ && - content.charCodeAt(1) === 33/*!*/) { + if (content.charCodeAt(0) === CHAR_HASH && + content.charCodeAt(1) === CHAR_EXCLAMATION_MARK) { if (contLen === 2) { // Exact match content = ''; @@ -75,7 +82,7 @@ function stripShebang(content) { var i = 2; for (; i < contLen; ++i) { var code = content.charCodeAt(i); - if (code === 10/*\n*/ || code === 13/*\r*/) + if (code === CHAR_LINE_FEED || code === CHAR_CARRIAGE_RETURN) break; } if (i === contLen) From ffab6cd5057bce6dbbcbe06b0eaa0f905aa43115 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 21 Feb 2018 15:49:47 +0100 Subject: [PATCH 43/47] src: fix abort when taking a heap snapshot Remove an erroneous CHECK that asserted the persistent object's internal field pointer still pointed to a valid object. If ClearWrap() has been called, the field pointer equals nullptr and that is expected behavior. PR-URL: https://github.com/nodejs/node/pull/18898 Fixes: https://github.com/nodejs/node/issues/18256 Reviewed-By: Colin Ihrig Reviewed-By: Joyee Cheung Reviewed-By: Ruben Bridgewater Reviewed-By: Anna Henningsen Reviewed-By: Matheus Marchini --- src/async_wrap.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/async_wrap.cc b/src/async_wrap.cc index a7eed82958c..08bb73f7468 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -124,7 +124,7 @@ RetainedObjectInfo* WrapperInfo(uint16_t class_id, Local wrapper) { CHECK_GT(object->InternalFieldCount(), 0); AsyncWrap* wrap = Unwrap(object); - CHECK_NE(nullptr, wrap); + if (wrap == nullptr) return nullptr; // ClearWrap() already called. return new RetainedAsyncInfo(class_id, wrap); } From 2b7f920e26171f05fac437d867a30209f57c6bad Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Mon, 19 Feb 2018 15:09:48 +0100 Subject: [PATCH 44/47] http: remove default 'drain' listener on upgrade Ensure that the default `'drain'` listener is removed before the `'connect'` or `'upgrade'` event is emitted. PR-URL: https://github.com/nodejs/node/pull/18866 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater --- lib/_http_client.js | 3 ++- test/parallel/test-http-connect.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index cab11ae8f29..311da63c5bf 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -37,7 +37,7 @@ const { OutgoingMessage } = require('_http_outgoing'); const Agent = require('_http_agent'); const { Buffer } = require('buffer'); const { urlToOptions, searchParamsSymbol } = require('internal/url'); -const { outHeadersKey } = require('internal/http'); +const { outHeadersKey, ondrain } = require('internal/http'); const { nextTick } = require('internal/process/next_tick'); const errors = require('internal/errors'); @@ -424,6 +424,7 @@ function socketOnData(d) { socket.removeListener('data', socketOnData); socket.removeListener('end', socketOnEnd); + socket.removeListener('drain', ondrain); parser.finish(); freeParser(parser, req, socket); diff --git a/test/parallel/test-http-connect.js b/test/parallel/test-http-connect.js index e7fb116de93..f90d235521a 100644 --- a/test/parallel/test-http-connect.js +++ b/test/parallel/test-http-connect.js @@ -74,6 +74,7 @@ server.listen(0, common.mustCall(() => { assert.strictEqual(socket._httpMessage, null); assert.strictEqual(socket.listeners('connect').length, 0); assert.strictEqual(socket.listeners('data').length, 0); + assert.strictEqual(socket.listeners('drain').length, 0); // the stream.Duplex onend listener // allow 0 here, so that i can run the same test on streams1 impl From 945eb1bb693216400bc222c56d607f182e2e2939 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Wed, 21 Feb 2018 11:28:13 -0500 Subject: [PATCH 45/47] 2018-02-22, Version 9.6.0 (Current) Notable changes: * async_hooks: - deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh) https://github.com/nodejs/node/pull/18513 - rename PromiseWrap.parentId to PromiseWrap.isChainedPromise (Ali Ijaz Sheikh) https://github.com/nodejs/node/pull/18633 * deps: - update node-inspect to 1.11.3 (Jan Krems) https://github.com/nodejs/node/pull/18354 - ICU 60.2 bump (Steven R. Loomis) https://github.com/nodejs/node/pull/17687 - Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems) https://github.com/nodejs/node/pull/16889 * http: - add options to http.createServer() for `IncomingMessage` and `ServerReponse` (Peter Marton) https://github.com/nodejs/node/pull/15752 * http2: - add http fallback options to .createServer (Peter Marton) https://github.com/nodejs/node/pull/15752 * https: - Adds the remaining options from tls.createSecureContext() to the string generated by Agent#getName(). This allows https.request() to accept the options and generate unique sockets appropriately. (Jeff Principe) https://github.com/nodejs/node/pull/16402 * inspector: - --inspect-brk for es modules (Guy Bedford) https://github.com/nodejs/node/pull/18194 * lib: - allow process kill by signal number (Sam Roberts) https://github.com/nodejs/node/pull/16944 * module: - enable dynamic import (Myles Borins) https://github.com/nodejs/node/pull/18387 - dynamic import is now supported (Jan Krems) https://github.com/nodejs/node/pull/15713 * napi: - add methods to open/close callback scope (Michael Dawson) https://github.com/nodejs/node/pull/18089 * src: - allow --perf-(basic-)?prof in NODE_OPTIONS (Leko) https://github.com/nodejs/node/pull/17600 * vm: - add support for es modules (Gus Caplan) https://github.com/nodejs/node/pull/17560 PR-URL: https://github.com/nodejs/node/pull/18902 --- CHANGELOG.md | 3 +- doc/api/async_hooks.md | 6 +- doc/api/http.md | 2 +- doc/api/http2.md | 2 +- doc/api/n-api.md | 4 +- doc/api/perf_hooks.md | 2 +- doc/api/vm.md | 2 +- doc/changelogs/CHANGELOG_V9.md | 241 +++++++++++++++++++++++++++++++++ 8 files changed, 252 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97b162993d5..17d2cd3e60b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,7 +29,8 @@ release. -9.5.0
+9.6.0
+9.5.0
9.4.0
9.3.0
9.2.1
diff --git a/doc/api/async_hooks.md b/doc/api/async_hooks.md index a96fd042930..1b1dfa119b7 100644 --- a/doc/api/async_hooks.md +++ b/doc/api/async_hooks.md @@ -673,7 +673,7 @@ class DBQuery extends AsyncResource { #### `asyncResource.runInAsyncScope(fn[, thisArg, ...args])` * `fn` {Function} The function to call in the execution context of this async @@ -688,7 +688,7 @@ then restore the original execution context. #### `asyncResource.emitBefore()` > Stability: 0 - Deprecated: Use [`asyncResource.runInAsyncScope()`][] instead. @@ -706,7 +706,7 @@ alternative. #### `asyncResource.emitAfter()` > Stability: 0 - Deprecated: Use [`asyncResource.runInAsyncScope()`][] instead. diff --git a/doc/api/http.md b/doc/api/http.md index e396471b3e9..a81be63afca 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -1716,7 +1716,7 @@ Found'`. diff --git a/doc/api/http2.md b/doc/api/http2.md index efacbe149b7..8eb92c9555a 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -1655,7 +1655,7 @@ changes: pr-url: https://github.com/nodejs/node/pull/16676 description: Added the `maxHeaderListPairs` option with a default limit of 128 header pairs. - - version: REPLACEME + - version: v9.6.0 pr-url: https://github.com/nodejs/node/pull/15752 description: Added the `Http1IncomingMessage` and `Http1ServerResponse` option. diff --git a/doc/api/n-api.md b/doc/api/n-api.md index 5ad6debfbe1..6f4924fcae9 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -3431,7 +3431,7 @@ may be required when implementing custom async behavior that does not use ### *napi_open_callback_scope* ```C NAPI_EXTERN napi_status napi_open_callback_scope(napi_env env, @@ -3456,7 +3456,7 @@ the required scope. ### *napi_close_callback_scope* ```C NAPI_EXTERN napi_status napi_close_callback_scope(napi_env env, diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index 608bee8d574..5bef91eafb7 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -127,7 +127,7 @@ to mark specific significant moments in the Performance Timeline. ### performance.maxEntries Value: {number} diff --git a/doc/api/vm.md b/doc/api/vm.md index e4ea6ca87a0..0a5999b7ffd 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -45,7 +45,7 @@ code**. ## Class: vm.Module > Stability: 1 - Experimental diff --git a/doc/changelogs/CHANGELOG_V9.md b/doc/changelogs/CHANGELOG_V9.md index 2f823638f80..1641a651898 100644 --- a/doc/changelogs/CHANGELOG_V9.md +++ b/doc/changelogs/CHANGELOG_V9.md @@ -8,6 +8,7 @@ +9.6.0
9.5.0
9.4.0
9.3.0
@@ -30,6 +31,246 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + +## 2018-02-22, Version 9.6.0 (Current), @MylesBorins + +### Notable Changes + +* **async_hooks**: + - deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh) [#18513](https://github.com/nodejs/node/pull/18513) + - rename PromiseWrap.parentId to PromiseWrap.isChainedPromise (Ali Ijaz Sheikh) [#18633](https://github.com/nodejs/node/pull/18633) +* **deps**: + - update node-inspect to 1.11.3 (Jan Krems) [#18354](https://github.com/nodejs/node/pull/18354) + - ICU 60.2 bump (Steven R. Loomis) [#17687](https://github.com/nodejs/node/pull/17687) + - Introduce ScriptOrModule and HostDefinedOptions to V8 (Jan Krems) [#16889](https://github.com/nodejs/node/pull/16889) +* **http**: + - add options to http.createServer() for `IncomingMessage` and `ServerReponse` (Peter Marton) [#15752](https://github.com/nodejs/node/pull/15752) +* **http2**: + - add http fallback options to .createServer (Peter Marton) [#15752](https://github.com/nodejs/node/pull/15752) +* **https**: + - Adds the remaining options from tls.createSecureContext() to the string generated by Agent#getName(). This allows https.request() to accept the options and generate unique sockets appropriately. (Jeff Principe) [#16402](https://github.com/nodejs/node/pull/16402) +* **inspector**: + - --inspect-brk for es modules (Guy Bedford) [#18194](https://github.com/nodejs/node/pull/18194) +* **lib**: + - allow process kill by signal number (Sam Roberts) [#16944](https://github.com/nodejs/node/pull/16944) +* **module**: + - enable dynamic import (Myles Borins) [#18387](https://github.com/nodejs/node/pull/18387) + - dynamic import is now supported (Jan Krems) [#15713](https://github.com/nodejs/node/pull/15713) +* **n-api**: + - add methods to open/close callback scope (Michael Dawson) [#18089](https://github.com/nodejs/node/pull/18089) +* **src**: + - allow --perf-(basic-)?prof in NODE_OPTIONS (Leko) [#17600](https://github.com/nodejs/node/pull/17600) +* **vm**: + - add support for es modules (Gus Caplan) [#17560](https://github.com/nodejs/node/pull/17560) + +### Commits + +* [[`7f5334e243`](https://github.com/nodejs/node/commit/7f5334e243)] - **(SEMVER-MINOR)** **async_hooks**: deprecate unsafe emit{Before,After} (Ali Ijaz Sheikh) [#18513](https://github.com/nodejs/node/pull/18513) +* [[`8e39c3bfd6`](https://github.com/nodejs/node/commit/8e39c3bfd6)] - **(SEMVER-MINOR)** **async_hooks**: rename PromiseWrap.parentId (Ali Ijaz Sheikh) [#18633](https://github.com/nodejs/node/pull/18633) +* [[`0865d11c08`](https://github.com/nodejs/node/commit/0865d11c08)] - **async_hooks**: clean up comments (Ali Ijaz Sheikh) [#18467](https://github.com/nodejs/node/pull/18467) +* [[`4d78eb8663`](https://github.com/nodejs/node/commit/4d78eb8663)] - **benchmark**: improve compare output (Ruben Bridgewater) [#18597](https://github.com/nodejs/node/pull/18597) +* [[`ffbad8350e`](https://github.com/nodejs/node/commit/ffbad8350e)] - **benchmark**: spread operator benchmark (James M Snell) [#18442](https://github.com/nodejs/node/pull/18442) +* [[`9ae513a7de`](https://github.com/nodejs/node/commit/9ae513a7de)] - **benchmark**: shorten config name in http benchmark (Joyee Cheung) [#18452](https://github.com/nodejs/node/pull/18452) +* [[`d469a06ace`](https://github.com/nodejs/node/commit/d469a06ace)] - **benchmark**: cut down http benchmark run time (Joyee Cheung) [#18379](https://github.com/nodejs/node/pull/18379) +* [[`9c125825a9`](https://github.com/nodejs/node/commit/9c125825a9)] - **benchmark**: refactor (Ruben Bridgewater) [#18320](https://github.com/nodejs/node/pull/18320) +* [[`f0186704cd`](https://github.com/nodejs/node/commit/f0186704cd)] - **benchmark**: (timers) refactor (Ruben Bridgewater) [#18320](https://github.com/nodejs/node/pull/18320) +* [[`28156e16d1`](https://github.com/nodejs/node/commit/28156e16d1)] - **benchmark**: (http(2)) refactor (Ruben Bridgewater) [#18320](https://github.com/nodejs/node/pull/18320) +* [[`076b3d9b0a`](https://github.com/nodejs/node/commit/076b3d9b0a)] - **benchmark**: (es) refactor (Ruben Bridgewater) [#18320](https://github.com/nodejs/node/pull/18320) +* [[`76cb958975`](https://github.com/nodejs/node/commit/76cb958975)] - **benchmark**: (url) refactor (Ruben Bridgewater) [#18320](https://github.com/nodejs/node/pull/18320) +* [[`0851822b87`](https://github.com/nodejs/node/commit/0851822b87)] - **benchmark**: (crypto) refactor (Ruben Bridgewater) [#18320](https://github.com/nodejs/node/pull/18320) +* [[`cb13c7c653`](https://github.com/nodejs/node/commit/cb13c7c653)] - **benchmark**: (buffer) refactor (Ruben Bridgewater) [#18320](https://github.com/nodejs/node/pull/18320) +* [[`9acf7545f0`](https://github.com/nodejs/node/commit/9acf7545f0)] - **benchmark**: (assert) refactor (Ruben Bridgewater) [#18320](https://github.com/nodejs/node/pull/18320) +* [[`7da01f43fd`](https://github.com/nodejs/node/commit/7da01f43fd)] - **benchmark**: fix variables not being set (Ruben Bridgewater) [#18320](https://github.com/nodejs/node/pull/18320) +* [[`4a5d7d4248`](https://github.com/nodejs/node/commit/4a5d7d4248)] - **benchmark**: fix platform in basename-win32 (Ruben Bridgewater) [#18320](https://github.com/nodejs/node/pull/18320) +* [[`f3ab106750`](https://github.com/nodejs/node/commit/f3ab106750)] - **buffer**: remove obsolete NaN check (Ruben Bridgewater) [#18744](https://github.com/nodejs/node/pull/18744) +* [[`c38576e526`](https://github.com/nodejs/node/commit/c38576e526)] - **buffer**: simplify check size in assertSize (Mihail Bodrov) [#18665](https://github.com/nodejs/node/pull/18665) +* [[`080368b5d0`](https://github.com/nodejs/node/commit/080368b5d0)] - **build**: no longer have v8-debug.h as dependency. (Yang Guo) [#18677](https://github.com/nodejs/node/pull/18677) +* [[`15db2969fe`](https://github.com/nodejs/node/commit/15db2969fe)] - **build**: do not suppress output in make doc-only (Joyee Cheung) [#18507](https://github.com/nodejs/node/pull/18507) +* [[`c642e229da`](https://github.com/nodejs/node/commit/c642e229da)] - **build**: add doc linting when runnning `make lint` (Camilo Gonzalez) [#18472](https://github.com/nodejs/node/pull/18472) +* [[`be5c293d73`](https://github.com/nodejs/node/commit/be5c293d73)] - **build**: allow x86_64 as a dest_cpu alias for x64 (Rod Vagg) [#18052](https://github.com/nodejs/node/pull/18052) +* [[`9c6bb5f386`](https://github.com/nodejs/node/commit/9c6bb5f386)] - **build**: add cflags for OpenBSD, remove stray comma. (Aaron Bieber) [#18448](https://github.com/nodejs/node/pull/18448) +* [[`2c7de9df50`](https://github.com/nodejs/node/commit/2c7de9df50)] - **build,win**: replace run-python subroutine with single find_python call (Nikolai Vavilov) [#18621](https://github.com/nodejs/node/pull/18621) +* [[`91f2cf9297`](https://github.com/nodejs/node/commit/91f2cf9297)] - **child_process**: fix stdio sockets creation (Santiago Gimeno) [#18701](https://github.com/nodejs/node/pull/18701) +* [[`a893b42791`](https://github.com/nodejs/node/commit/a893b42791)] - **crypto**: use non-deprecated v8::Object::Set (Daniel Bevenius) [#17482](https://github.com/nodejs/node/pull/17482) +* [[`2d98b58c08`](https://github.com/nodejs/node/commit/2d98b58c08)] - **deps**: V8: backport 76c3ac5 from upstream (Ali Ijaz Sheikh) [#18298](https://github.com/nodejs/node/pull/18298) +* [[`442903fb1b`](https://github.com/nodejs/node/commit/442903fb1b)] - **deps**: update node-inspect to 1.11.3 (Jan Krems) [#18354](https://github.com/nodejs/node/pull/18354) +* [[`9e7f8633b6`](https://github.com/nodejs/node/commit/9e7f8633b6)] - **deps**: ICU 60.2 bump (Steven R. Loomis) [#17687](https://github.com/nodejs/node/pull/17687) +* [[`11566fe532`](https://github.com/nodejs/node/commit/11566fe532)] - **deps**: cherry-pick dbfe4a49d8 from upstream V8 (Jan Krems) [#16889](https://github.com/nodejs/node/pull/16889) +* [[`6edf952628`](https://github.com/nodejs/node/commit/6edf952628)] - **doc**: fix nits in tools/doc/README.md (Vse Mozhet Byt) [#18874](https://github.com/nodejs/node/pull/18874) +* [[`7624686888`](https://github.com/nodejs/node/commit/7624686888)] - **doc**: fix minor grammar/typographical issues in onboarding.md (Rich Trott) [#18847](https://github.com/nodejs/node/pull/18847) +* [[`2f836e76bd`](https://github.com/nodejs/node/commit/2f836e76bd)] - **doc**: update onboarding.md for faster exercise completion (Rich Trott) [#18846](https://github.com/nodejs/node/pull/18846) +* [[`e1f82735fe`](https://github.com/nodejs/node/commit/e1f82735fe)] - **doc**: improved documentation for fs.unlink() (dustinnewman98) [#18843](https://github.com/nodejs/node/pull/18843) +* [[`63b0c158f7`](https://github.com/nodejs/node/commit/63b0c158f7)] - **doc**: fix broken link in pull-requests.md (Justin Lee) [#18873](https://github.com/nodejs/node/pull/18873) +* [[`8047c27855`](https://github.com/nodejs/node/commit/8047c27855)] - **doc**: fix typo in http2.md (Vse Mozhet Byt) [#18872](https://github.com/nodejs/node/pull/18872) +* [[`0dd8ea4a00`](https://github.com/nodejs/node/commit/0dd8ea4a00)] - **doc**: refactor manpage to use mdoc(7) macros (Alhadis) [#18559](https://github.com/nodejs/node/pull/18559) +* [[`33271e60f3`](https://github.com/nodejs/node/commit/33271e60f3)] - **doc**: mark accessing IPC channel fd as undefined (Bartosz Sosnowski) [#17545](https://github.com/nodejs/node/pull/17545) +* [[`02e9e9949c`](https://github.com/nodejs/node/commit/02e9e9949c)] - **doc**: fix minor typos in GOVERNANCE.md (Rich Trott) [#18829](https://github.com/nodejs/node/pull/18829) +* [[`1bff0aaae5`](https://github.com/nodejs/node/commit/1bff0aaae5)] - **doc**: add Yihong Wang to collaborators (Yihong Wang) [#18824](https://github.com/nodejs/node/pull/18824) +* [[`1c77929231`](https://github.com/nodejs/node/commit/1c77929231)] - **doc**: warn against concurrent http2stream.respondWithFD (Anna Henningsen) [#18762](https://github.com/nodejs/node/pull/18762) +* [[`cd2fa0412f`](https://github.com/nodejs/node/commit/cd2fa0412f)] - **doc**: activate `no-multiple-empty-lines` rule (Ruben Bridgewater) [#18747](https://github.com/nodejs/node/pull/18747) +* [[`20ad397f93`](https://github.com/nodejs/node/commit/20ad397f93)] - **doc**: note that linting is required in releases.md (Gibson Fahnestock) [#18776](https://github.com/nodejs/node/pull/18776) +* [[`0fc33fb282`](https://github.com/nodejs/node/commit/0fc33fb282)] - **doc**: remove extra space in README.md (Matheus Marchini) [#18822](https://github.com/nodejs/node/pull/18822) +* [[`9bec493510`](https://github.com/nodejs/node/commit/9bec493510)] - **doc**: update crypo Certficate class. (Antoine AMARA) [#18721](https://github.com/nodejs/node/pull/18721) +* [[`17d4dd5cce`](https://github.com/nodejs/node/commit/17d4dd5cce)] - **doc**: move Fedor to TSC Emeritus (Myles Borins) [#18752](https://github.com/nodejs/node/pull/18752) +* [[`92ed0710da`](https://github.com/nodejs/node/commit/92ed0710da)] - **doc**: add mmarchini to collaborators (Matheus Marchini) [#18740](https://github.com/nodejs/node/pull/18740) +* [[`b5073a0744`](https://github.com/nodejs/node/commit/b5073a0744)] - **doc**: mark NAPI_AUTO_LENGTH as code (Tobias Nießen) [#18697](https://github.com/nodejs/node/pull/18697) +* [[`3cfb313e8e`](https://github.com/nodejs/node/commit/3cfb313e8e)] - **doc**: add error check to fs example (Evan Lucas) [#18681](https://github.com/nodejs/node/pull/18681) +* [[`876e186573`](https://github.com/nodejs/node/commit/876e186573)] - **doc**: fix exporting a function example (Aonghus O Nia) [#18661](https://github.com/nodejs/node/pull/18661) +* [[`7b377cffdb`](https://github.com/nodejs/node/commit/7b377cffdb)] - **doc**: add history for url.parse (Steven) [#18685](https://github.com/nodejs/node/pull/18685) +* [[`4981e98889`](https://github.com/nodejs/node/commit/4981e98889)] - **doc**: fix links to Style Guide and CPP Style Guide (Justin Lee) [#18683](https://github.com/nodejs/node/pull/18683) +* [[`af977dbf49`](https://github.com/nodejs/node/commit/af977dbf49)] - **doc**: add devsnek to collaborators (Gus Caplan) [#18679](https://github.com/nodejs/node/pull/18679) +* [[`f0f01039b4`](https://github.com/nodejs/node/commit/f0f01039b4)] - **doc**: fix links in YAML metadata of assert.md (Vse Mozhet Byt) [#18670](https://github.com/nodejs/node/pull/18670) +* [[`832e0522eb`](https://github.com/nodejs/node/commit/832e0522eb)] - **doc**: add missing meta for createCipheriv (Tobias Nießen) [#18651](https://github.com/nodejs/node/pull/18651) +* [[`affddd372a`](https://github.com/nodejs/node/commit/affddd372a)] - **doc**: fix description of createDecipheriv (Tobias Nießen) [#18651](https://github.com/nodejs/node/pull/18651) +* [[`4722004900`](https://github.com/nodejs/node/commit/4722004900)] - **doc**: fix MDN links to avoid redirections (Vse Mozhet Byt) [#18631](https://github.com/nodejs/node/pull/18631) +* [[`e7508e5fcd`](https://github.com/nodejs/node/commit/e7508e5fcd)] - **doc**: fix link in https.md (Vse Mozhet Byt) [#18630](https://github.com/nodejs/node/pull/18630) +* [[`dc4da22220`](https://github.com/nodejs/node/commit/dc4da22220)] - **doc**: be more explicit in the sypnosis (Tim O. Peters) [#17977](https://github.com/nodejs/node/pull/17977) +* [[`54391548d0`](https://github.com/nodejs/node/commit/54391548d0)] - **doc**: add missing "changes" key in YAML comment (Luigi Pinca) [#18605](https://github.com/nodejs/node/pull/18605) +* [[`7241fa0fbd`](https://github.com/nodejs/node/commit/7241fa0fbd)] - **doc**: fix typo in http2.md (Vse Mozhet Byt) [#18602](https://github.com/nodejs/node/pull/18602) +* [[`7a432c1af3`](https://github.com/nodejs/node/commit/7a432c1af3)] - **doc**: update onboarding-extras (Gus Caplan) [#18545](https://github.com/nodejs/node/pull/18545) +* [[`c18d958750`](https://github.com/nodejs/node/commit/c18d958750)] - **doc**: modify the return value of request.write() (陈刚) [#18526](https://github.com/nodejs/node/pull/18526) +* [[`e8a75ee113`](https://github.com/nodejs/node/commit/e8a75ee113)] - **doc**: fix typo in n-api.md (Vse Mozhet Byt) [#18590](https://github.com/nodejs/node/pull/18590) +* [[`4f521c7896`](https://github.com/nodejs/node/commit/4f521c7896)] - **doc**: add introduce about cli options (Weijia Wang) [#18475](https://github.com/nodejs/node/pull/18475) +* [[`4dea9e03d6`](https://github.com/nodejs/node/commit/4dea9e03d6)] - **doc**: small typo in n-api.md (iskore) [#18555](https://github.com/nodejs/node/pull/18555) +* [[`6256d70916`](https://github.com/nodejs/node/commit/6256d70916)] - **doc**: add section for strategic initiatives (Michael Dawson) [#17104](https://github.com/nodejs/node/pull/17104) +* [[`5f0b3431e1`](https://github.com/nodejs/node/commit/5f0b3431e1)] - **doc**: remove usage of you in n-api doc (Michael Dawson) [#18528](https://github.com/nodejs/node/pull/18528) +* [[`2418c86c1e`](https://github.com/nodejs/node/commit/2418c86c1e)] - **doc**: expand on promises and async_hooks (Ali Ijaz Sheikh) [#18540](https://github.com/nodejs/node/pull/18540) +* [[`a7ad003e37`](https://github.com/nodejs/node/commit/a7ad003e37)] - **doc**: shell option for the execFile and execFileSync functions (jvelezpo) [#18237](https://github.com/nodejs/node/pull/18237) +* [[`dae86b3edb`](https://github.com/nodejs/node/commit/dae86b3edb)] - **doc**: improve http.request documentation (Guangcong Luo) [#18289](https://github.com/nodejs/node/pull/18289) +* [[`ffc8e8eb40`](https://github.com/nodejs/node/commit/ffc8e8eb40)] - **doc**: remove removed apis from http2 docs (Kelvin Jin) [#18439](https://github.com/nodejs/node/pull/18439) +* [[`25a7bdece5`](https://github.com/nodejs/node/commit/25a7bdece5)] - **doc**: streamline README intro (Rich Trott) [#18483](https://github.com/nodejs/node/pull/18483) +* [[`58003d4ddf`](https://github.com/nodejs/node/commit/58003d4ddf)] - **doc**: move Brian White to TSC Emeriti list (Rich Trott) [#18482](https://github.com/nodejs/node/pull/18482) +* [[`74a823c788`](https://github.com/nodejs/node/commit/74a823c788)] - **doc**: improve stream documentation (陈刚) [#18375](https://github.com/nodejs/node/pull/18375) +* [[`ae372f0e3d`](https://github.com/nodejs/node/commit/ae372f0e3d)] - **doc**: linkify missing types (Vse Mozhet Byt) [#18444](https://github.com/nodejs/node/pull/18444) +* [[`22093abbc8`](https://github.com/nodejs/node/commit/22093abbc8)] - **doc**: add Gibson Fahnestock to TSC (Rich Trott) [#18481](https://github.com/nodejs/node/pull/18481) +* [[`61d4e1d207`](https://github.com/nodejs/node/commit/61d4e1d207)] - **doc**: reorder section on updating PR branch (Ali Ijaz Sheikh) [#18355](https://github.com/nodejs/node/pull/18355) +* [[`8a627b17a4`](https://github.com/nodejs/node/commit/8a627b17a4)] - **doc**: add pending-deprecation to COLLABORATOR_GUIDE (Сковорода Никита Андреевич) [#18433](https://github.com/nodejs/node/pull/18433) +* [[`b76e111ee4`](https://github.com/nodejs/node/commit/b76e111ee4)] - **doc**: fix manpage warnings (Roman Reiss) +* [[`b841abc328`](https://github.com/nodejs/node/commit/b841abc328)] - **doc**: warn about GCM authenticity (Tobias Nießen) [#18376](https://github.com/nodejs/node/pull/18376) +* [[`2d968ca0d5`](https://github.com/nodejs/node/commit/2d968ca0d5)] - **doc**: Update tools/icu/README.md (Steven R. Loomis) [#16939](https://github.com/nodejs/node/pull/16939) +* [[`8c6dc62dc4`](https://github.com/nodejs/node/commit/8c6dc62dc4)] - **doc**: dedupe links (Vse Mozhet Byt) [#18213](https://github.com/nodejs/node/pull/18213) +* [[`6b1a40e914`](https://github.com/nodejs/node/commit/6b1a40e914)] - **doc**: capitalize non-primitive types (Vse Mozhet Byt) [#18111](https://github.com/nodejs/node/pull/18111) +* [[`44bf0f4f12`](https://github.com/nodejs/node/commit/44bf0f4f12)] - **domain**: further abstract usage in C++ (Anatoli Papirovski) [#18291](https://github.com/nodejs/node/pull/18291) +* [[`35471bcfdf`](https://github.com/nodejs/node/commit/35471bcfdf)] - **domain**: fix error emit handling (Anatoli Papirovski) [#17588](https://github.com/nodejs/node/pull/17588) +* [[`28edc1db99`](https://github.com/nodejs/node/commit/28edc1db99)] - **events**: use Reflect.apply (Anatoli Papirovski) [#17456](https://github.com/nodejs/node/pull/17456) +* [[`3ae5cf205f`](https://github.com/nodejs/node/commit/3ae5cf205f)] - **events**: move domain handling from events to domain (vdeturckheim) [#17403](https://github.com/nodejs/node/pull/17403) +* [[`0568f755da`](https://github.com/nodejs/node/commit/0568f755da)] - **fs**: remove useless comments which duplicate names of variables (Sergey Golovin) [#18739](https://github.com/nodejs/node/pull/18739) +* [[`5b75572494`](https://github.com/nodejs/node/commit/5b75572494)] - **fs**: replace magic numbers by named constants (Sergey Golovin) [#18757](https://github.com/nodejs/node/pull/18757) +* [[`35ce3a8931`](https://github.com/nodejs/node/commit/35ce3a8931)] - **fs**: make URL paths no longer experimental (James M Snell) [#18591](https://github.com/nodejs/node/pull/18591) +* [[`34f49343ee`](https://github.com/nodejs/node/commit/34f49343ee)] - **fs**: fix stack overflow in fs.readdirSync (Joyee Cheung) [#18647](https://github.com/nodejs/node/pull/18647) +* [[`6ce8b24c6d`](https://github.com/nodejs/node/commit/6ce8b24c6d)] - **http**: simplify checkInvalidHeaderChar (Seth Brenith) [#18381](https://github.com/nodejs/node/pull/18381) +* [[`c247cb02a1`](https://github.com/nodejs/node/commit/c247cb02a1)] - **(SEMVER-MINOR)** **http**: add options to http.createServer() (Peter Marton) [#15752](https://github.com/nodejs/node/pull/15752) +* [[`935eac189d`](https://github.com/nodejs/node/commit/935eac189d)] - **http**: remove domain specific code (Anatoli Papirovski) [#18477](https://github.com/nodejs/node/pull/18477) +* [[`8b2a272772`](https://github.com/nodejs/node/commit/8b2a272772)] - **http**: process headers after setting up agent (Rod Vagg) [#16568](https://github.com/nodejs/node/pull/16568) +* [[`d76403985f`](https://github.com/nodejs/node/commit/d76403985f)] - **http**: switch on string values (Seth Brenith) [#18351](https://github.com/nodejs/node/pull/18351) +* [[`5e5276b418`](https://github.com/nodejs/node/commit/5e5276b418)] - **http2**: use `_final` instead of `on('finish')` (Anna Henningsen) [#18609](https://github.com/nodejs/node/pull/18609) +* [[`c0d6945f4c`](https://github.com/nodejs/node/commit/c0d6945f4c)] - **http2**: add req and res options to server creation (Peter Marton) [#15560](https://github.com/nodejs/node/pull/15560) +* [[`7806c51f30`](https://github.com/nodejs/node/commit/7806c51f30)] - **(SEMVER-MINOR)** **http2**: add http fallback options to .createServer (Peter Marton) [#15752](https://github.com/nodejs/node/pull/15752) +* [[`7c682f2fd0`](https://github.com/nodejs/node/commit/7c682f2fd0)] - **(SEMVER-MINOR)** **https**: add extra options to Agent#getName() (Jeff Principe) [#16402](https://github.com/nodejs/node/pull/16402) +* [[`74051c64aa`](https://github.com/nodejs/node/commit/74051c64aa)] - **inspector**: --inspect-brk for es modules (Guy Bedford) [#18194](https://github.com/nodejs/node/pull/18194) +* [[`741e82e710`](https://github.com/nodejs/node/commit/741e82e710)] - **(SEMVER-MINOR)** **lib**: allow process kill by signal number (Sam Roberts) [#16944](https://github.com/nodejs/node/pull/16944) +* [[`810925bc17`](https://github.com/nodejs/node/commit/810925bc17)] - **lib**: replace `eval` with `vm.runInThisContext` (Myles Borins) [#18623](https://github.com/nodejs/node/pull/18623) +* [[`16aeddda24`](https://github.com/nodejs/node/commit/16aeddda24)] - **lib**: switch to Number.isNaN (Ruben Bridgewater) [#18744](https://github.com/nodejs/node/pull/18744) +* [[`1557d93a2b`](https://github.com/nodejs/node/commit/1557d93a2b)] - **lib**: set process.execPath on OpenBSD (Aaron Bieber) [#18543](https://github.com/nodejs/node/pull/18543) +* [[`0a97e1d2c0`](https://github.com/nodejs/node/commit/0a97e1d2c0)] - **lib**: provide proper deprecation code (Ruben Bridgewater) [#18694](https://github.com/nodejs/node/pull/18694) +* [[`51a8e1d2d8`](https://github.com/nodejs/node/commit/51a8e1d2d8)] - **lib**: remove debugger dead code (Qingyan Li) [#18426](https://github.com/nodejs/node/pull/18426) +* [[`650ec2d8f1`](https://github.com/nodejs/node/commit/650ec2d8f1)] - **lib**: extract validation functions (Timothy O. Peters) [#18421](https://github.com/nodejs/node/pull/18421) +* [[`1fd1395ee9`](https://github.com/nodejs/node/commit/1fd1395ee9)] - **lib,doc**: revert format name to cjs over commonjs (Guy Bedford) [#18596](https://github.com/nodejs/node/pull/18596) +* [[`cb36b6733c`](https://github.com/nodejs/node/commit/cb36b6733c)] - **loader**: fix up #18394 (Gus Caplan) [#18509](https://github.com/nodejs/node/pull/18509) +* [[`afc87c22d0`](https://github.com/nodejs/node/commit/afc87c22d0)] - **module**: refactor loader (Gus Caplan) [#16874](https://github.com/nodejs/node/pull/16874) +* [[`d89f310127`](https://github.com/nodejs/node/commit/d89f310127)] - **module**: enable dynamic import flag for esmodules (Myles Borins) [#18387](https://github.com/nodejs/node/pull/18387) +* [[`00d5422c43`](https://github.com/nodejs/node/commit/00d5422c43)] - **module**: Set dynamic import callback (Jan Krems) [#15713](https://github.com/nodejs/node/pull/15713) +* [[`9c818cfa83`](https://github.com/nodejs/node/commit/9c818cfa83)] - **n-api**: remove extra reference from test (Gabriel Schulhof) [#18542](https://github.com/nodejs/node/pull/18542) +* [[`4bf8b6a62d`](https://github.com/nodejs/node/commit/4bf8b6a62d)] - **(SEMVER-MINOR)** **n-api**: add methods to open/close callback scope (Michael Dawson) [#18089](https://github.com/nodejs/node/pull/18089) +* [[`d2581120da`](https://github.com/nodejs/node/commit/d2581120da)] - **n-api**: wrap control flow macro in do/while (Ben Noordhuis) [#18532](https://github.com/nodejs/node/pull/18532) +* [[`ae8f5db1b1`](https://github.com/nodejs/node/commit/ae8f5db1b1)] - **n-api**: implement wrapping using private properties (Gabriel Schulhof) [#18311](https://github.com/nodejs/node/pull/18311) +* [[`a07cd06e6c`](https://github.com/nodejs/node/commit/a07cd06e6c)] - **n-api**: change assert ok check to notStrictEqual. (Aaron Kau) [#18414](https://github.com/nodejs/node/pull/18414) +* [[`b9ea4c46e5`](https://github.com/nodejs/node/commit/b9ea4c46e5)] - **net**: simplify net.Socket#end() (Anna Henningsen) [#18708](https://github.com/nodejs/node/pull/18708) +* [[`6ed4e690e4`](https://github.com/nodejs/node/commit/6ed4e690e4)] - **net**: remove Socket.prototoype.read (Anna Henningsen) [#18568](https://github.com/nodejs/node/pull/18568) +* [[`958f5eda9a`](https://github.com/nodejs/node/commit/958f5eda9a)] - **net**: remove redundant code from _writeGeneric() (Luigi Pinca) [#18429](https://github.com/nodejs/node/pull/18429) +* [[`25ce45825f`](https://github.com/nodejs/node/commit/25ce45825f)] - **net,src**: refactor writeQueueSize tracking (Anatoli Papirovski) [#17650](https://github.com/nodejs/node/pull/17650) +* [[`3439635763`](https://github.com/nodejs/node/commit/3439635763)] - **path**: replace duplicate conditions by functions (Sergey Golovin) [#18693](https://github.com/nodejs/node/pull/18693) +* [[`5331454a30`](https://github.com/nodejs/node/commit/5331454a30)] - **path**: replace "magic" numbers by readable constants (Sergey Golovin) [#18654](https://github.com/nodejs/node/pull/18654) +* [[`0a47b98f04`](https://github.com/nodejs/node/commit/0a47b98f04)] - **perf_hooks**: add warning when too many entries in the timeline (James M Snell) [#18087](https://github.com/nodejs/node/pull/18087) +* [[`cec3d1ea80`](https://github.com/nodejs/node/commit/cec3d1ea80)] - **process**: fix reading zero-length env vars on win32 (Anna Henningsen) [#18463](https://github.com/nodejs/node/pull/18463) +* [[`36332eba27`](https://github.com/nodejs/node/commit/36332eba27)] - **readline**: use Date.now() and move test to parallel (Anatoli Papirovski) [#18563](https://github.com/nodejs/node/pull/18563) +* [[`9957916c26`](https://github.com/nodejs/node/commit/9957916c26)] - **src**: add nullptr check for session in DEBUG macro (Daniel Bevenius) [#18815](https://github.com/nodejs/node/pull/18815) +* [[`de3231c13a`](https://github.com/nodejs/node/commit/de3231c13a)] - **src**: factor out some common vm functions (Timothy Gu) [#17560](https://github.com/nodejs/node/pull/17560) +* [[`a258f6b5ce`](https://github.com/nodejs/node/commit/a258f6b5ce)] - **src**: flatten ContextifyContext (Gus Caplan) [#17560](https://github.com/nodejs/node/pull/17560) +* [[`a7419d0902`](https://github.com/nodejs/node/commit/a7419d0902)] - **src**: replace var for let / const. (alejandro estrada) [#18649](https://github.com/nodejs/node/pull/18649) +* [[`d190c9a41e`](https://github.com/nodejs/node/commit/d190c9a41e)] - **src**: add "icu::" prefix before ICU symbols (Steven R. Loomis) +* [[`3ec3c329c6`](https://github.com/nodejs/node/commit/3ec3c329c6)] - **src**: fix crypto.pbkdf2 callback error argument (BufoViridis) [#18458](https://github.com/nodejs/node/pull/18458) +* [[`464df6d9b5`](https://github.com/nodejs/node/commit/464df6d9b5)] - **(SEMVER-MINOR)** **src**: allow --perf-(basic-)?prof in NODE_OPTIONS (Leko) [#17600](https://github.com/nodejs/node/pull/17600) +* [[`43956e9600`](https://github.com/nodejs/node/commit/43956e9600)] - **src**: free memory before re-setting URLHost value (Ivan Filenko) [#18357](https://github.com/nodejs/node/pull/18357) +* [[`272fd2e334`](https://github.com/nodejs/node/commit/272fd2e334)] - **src**: fix vector subscript out of range (Anatoli Papirovski) [#18460](https://github.com/nodejs/node/pull/18460) +* [[`64c36d31b6`](https://github.com/nodejs/node/commit/64c36d31b6)] - **src, lib**: return promises from link (Gus Caplan) [#18394](https://github.com/nodejs/node/pull/18394) +* [[`ba46103291`](https://github.com/nodejs/node/commit/ba46103291)] - **stream**: fix misleading error message (Luigi Pinca) [#18604](https://github.com/nodejs/node/pull/18604) +* [[`27532f4e9a`](https://github.com/nodejs/node/commit/27532f4e9a)] - **stream**: cleanup() when unpiping all streams. (陈刚) [#18266](https://github.com/nodejs/node/pull/18266) +* [[`a4cc0fb1b6`](https://github.com/nodejs/node/commit/a4cc0fb1b6)] - **stream**: delete unused code (陈刚) [#18278](https://github.com/nodejs/node/pull/18278) +* [[`450f5f43bc`](https://github.com/nodejs/node/commit/450f5f43bc)] - **stream**: delete redundant code (陈刚) [#18145](https://github.com/nodejs/node/pull/18145) +* [[`560f657957`](https://github.com/nodejs/node/commit/560f657957)] - **stream**: delete redundant code (陈刚) [#18145](https://github.com/nodejs/node/pull/18145) +* [[`9af1e4b286`](https://github.com/nodejs/node/commit/9af1e4b286)] - **string_decoder**: reset decoder on end (Justin Ridgewell) [#18494](https://github.com/nodejs/node/pull/18494) +* [[`b02f4e1902`](https://github.com/nodejs/node/commit/b02f4e1902)] - **test**: http2 client settings invalid callback (Trivikram) [#18850](https://github.com/nodejs/node/pull/18850) +* [[`b7e6ac78fe`](https://github.com/nodejs/node/commit/b7e6ac78fe)] - **test**: http2 client ping errors (Trivikram) [#18849](https://github.com/nodejs/node/pull/18849) +* [[`f90490d475`](https://github.com/nodejs/node/commit/f90490d475)] - **test**: http2 client operations after destroy (Trivikram) [#18845](https://github.com/nodejs/node/pull/18845) +* [[`d73f214380`](https://github.com/nodejs/node/commit/d73f214380)] - **test**: refactor parallel/test-tls-pause (juggernaut451) [#18714](https://github.com/nodejs/node/pull/18714) +* [[`fa0b987a71`](https://github.com/nodejs/node/commit/fa0b987a71)] - **test**: refactor stream-*-constructor-set-methods (Luigi Pinca) [#18817](https://github.com/nodejs/node/pull/18817) +* [[`dba5e35326`](https://github.com/nodejs/node/commit/dba5e35326)] - **test**: refactor parallel/test-tls-0-dns-altname (juggernaut451) [#18803](https://github.com/nodejs/node/pull/18803) +* [[`f960ad491c`](https://github.com/nodejs/node/commit/f960ad491c)] - **test**: add common.skipIfEslintMissing (Myles Borins) [#18807](https://github.com/nodejs/node/pull/18807) +* [[`dc456853f8`](https://github.com/nodejs/node/commit/dc456853f8)] - **test**: fix warnings in addon tests (Ali Ijaz Sheikh) [#18810](https://github.com/nodejs/node/pull/18810) +* [[`7874cb0f3c`](https://github.com/nodejs/node/commit/7874cb0f3c)] - **test**: refactor parallel/test-tls-addca (juggernaut451) [#18798](https://github.com/nodejs/node/pull/18798) +* [[`b3b5ac5169`](https://github.com/nodejs/node/commit/b3b5ac5169)] - **test**: refactor of test-tls-over-http-tunnel (juggernaut451) [#18784](https://github.com/nodejs/node/pull/18784) +* [[`849f5c31c8`](https://github.com/nodejs/node/commit/849f5c31c8)] - **test**: make tls test more rigorous (Ben Noordhuis) [#18792](https://github.com/nodejs/node/pull/18792) +* [[`cf10a94b48`](https://github.com/nodejs/node/commit/cf10a94b48)] - **test**: reduce benchmark test run time (juggernaut451) [#18787](https://github.com/nodejs/node/pull/18787) +* [[`8b5ca482fa`](https://github.com/nodejs/node/commit/8b5ca482fa)] - **test**: try to connect after server was closed (Leko) [#18257](https://github.com/nodejs/node/pull/18257) +* [[`75c691b788`](https://github.com/nodejs/node/commit/75c691b788)] - **test**: wrap countdown callback in common.mustCall (Bamieh) [#18506](https://github.com/nodejs/node/pull/18506) +* [[`ed55374b98`](https://github.com/nodejs/node/commit/ed55374b98)] - **test**: update a few tests to work on OpenBSD (Aaron Bieber) [#18543](https://github.com/nodejs/node/pull/18543) +* [[`7e75a78c5a`](https://github.com/nodejs/node/commit/7e75a78c5a)] - **test**: add lib path env when node_shared=true (Yihong Wang) [#18626](https://github.com/nodejs/node/pull/18626) +* [[`d6786d2110`](https://github.com/nodejs/node/commit/d6786d2110)] - **test**: add multiline repl input regression test (cjihrig) [#18718](https://github.com/nodejs/node/pull/18718) +* [[`18c493397f`](https://github.com/nodejs/node/commit/18c493397f)] - **test**: remove unnecessary timer (cjihrig) [#18719](https://github.com/nodejs/node/pull/18719) +* [[`5b88cb747e`](https://github.com/nodejs/node/commit/5b88cb747e)] - **test**: add crypto check to test-benchmark-tls (Daniel Bevenius) [#18724](https://github.com/nodejs/node/pull/18724) +* [[`6c041638c3`](https://github.com/nodejs/node/commit/6c041638c3)] - **test**: fix missing param in benchmark-timers (Anatoli Papirovski) [#18734](https://github.com/nodejs/node/pull/18734) +* [[`3362ae79df`](https://github.com/nodejs/node/commit/3362ae79df)] - **test**: fix and improve error message (Kevin Caulfield) [#18449](https://github.com/nodejs/node/pull/18449) +* [[`e9c9200aba`](https://github.com/nodejs/node/commit/e9c9200aba)] - **test**: add useful info to error msg and refactor (Chin Huang) [#18541](https://github.com/nodejs/node/pull/18541) +* [[`72d71594bd`](https://github.com/nodejs/node/commit/72d71594bd)] - **test**: fix flaky repl-timeout-throw (Santiago Gimeno) [#18692](https://github.com/nodejs/node/pull/18692) +* [[`2089814b67`](https://github.com/nodejs/node/commit/2089814b67)] - **test**: properly tag anonymous namespaces (Michael Dawson) [#18583](https://github.com/nodejs/node/pull/18583) +* [[`a667ac1665`](https://github.com/nodejs/node/commit/a667ac1665)] - **test**: fix flaky timers-block-eventloop test (Anatoli Papirovski) [#18567](https://github.com/nodejs/node/pull/18567) +* [[`f3e6c7636a`](https://github.com/nodejs/node/commit/f3e6c7636a)] - **test**: refactor test-http-abort-before-end (cjihrig) [#18508](https://github.com/nodejs/node/pull/18508) +* [[`0277993f49`](https://github.com/nodejs/node/commit/0277993f49)] - **test**: improve error message output (Bhavani Shankar) [#18498](https://github.com/nodejs/node/pull/18498) +* [[`30a233cfce`](https://github.com/nodejs/node/commit/30a233cfce)] - **test**: fix flaky test-http2-session-unref (Anatoli Papirovski) [#18589](https://github.com/nodejs/node/pull/18589) +* [[`ef2d9c2c54`](https://github.com/nodejs/node/commit/ef2d9c2c54)] - **test**: do not check TXT content in test-dns-any (Joyee Cheung) [#18547](https://github.com/nodejs/node/pull/18547) +* [[`10dc25df83`](https://github.com/nodejs/node/commit/10dc25df83)] - **test**: improve tests for test-http-url.parse (Weijia Wang) [#18523](https://github.com/nodejs/node/pull/18523) +* [[`a13fbdd4c3`](https://github.com/nodejs/node/commit/a13fbdd4c3)] - **test**: remove destructor from node_test_fixture (Daniel Bevenius) [#18524](https://github.com/nodejs/node/pull/18524) +* [[`52aeb2a070`](https://github.com/nodejs/node/commit/52aeb2a070)] - **test**: verify the shell option works properly on execFile (jvelezpo) [#18384](https://github.com/nodejs/node/pull/18384) +* [[`0d390f7bdf`](https://github.com/nodejs/node/commit/0d390f7bdf)] - **test**: add test for tls benchmarks (Anatoli Papirovski) [#18489](https://github.com/nodejs/node/pull/18489) +* [[`da0d776593`](https://github.com/nodejs/node/commit/da0d776593)] - **test**: mark test-inspector-stop-profile-after-done flaky (Myles Borins) [#18491](https://github.com/nodejs/node/pull/18491) +* [[`8c9b41aaee`](https://github.com/nodejs/node/commit/8c9b41aaee)] - **test**: show pending exception error in napi tests (Ben Wilcox) [#18413](https://github.com/nodejs/node/pull/18413) +* [[`f6c9a2bc47`](https://github.com/nodejs/node/commit/f6c9a2bc47)] - **test**: speed up parallel/test-tls-session-cache (Anna Henningsen) [#18424](https://github.com/nodejs/node/pull/18424) +* [[`6b74064e65`](https://github.com/nodejs/node/commit/6b74064e65)] - **test**: fix flaky test-http-dns-error (Bryan English) [#16534](https://github.com/nodejs/node/pull/16534) +* [[`eb252527e5`](https://github.com/nodejs/node/commit/eb252527e5)] - **test**: move tmpdir to submodule of common (Rich Trott) [#17856](https://github.com/nodejs/node/pull/17856) +* [[`b5267a6926`](https://github.com/nodejs/node/commit/b5267a6926)] - **test**: force context allocation in test module (Yang Guo) [#18312](https://github.com/nodejs/node/pull/18312) +* [[`cc8091448b`](https://github.com/nodejs/node/commit/cc8091448b)] - **test**: fix flaky cluster unix socket test (Ben Noordhuis) [#17407](https://github.com/nodejs/node/pull/17407) +* [[`19abee149d`](https://github.com/nodejs/node/commit/19abee149d)] - **test**: fix a bug & lint issues in inspector-helper (Anatoli Papirovski) [#18293](https://github.com/nodejs/node/pull/18293) +* [[`b5752ee6a4`](https://github.com/nodejs/node/commit/b5752ee6a4)] - **test**: fix require-deps-deprecation for installed deps (Benjamin Zaslavsky) [#17848](https://github.com/nodejs/node/pull/17848) +* [[`66f8d346b8`](https://github.com/nodejs/node/commit/66f8d346b8)] - **test,benchmark,doc**: enable dot-notation rule (Ruben Bridgewater) [#18749](https://github.com/nodejs/node/pull/18749) +* [[`146e8ac83a`](https://github.com/nodejs/node/commit/146e8ac83a)] - **timers**: remove domain specific code (Anatoli Papirovski) [#18477](https://github.com/nodejs/node/pull/18477) +* [[`f8f1423e7a`](https://github.com/nodejs/node/commit/f8f1423e7a)] - **tls**: tls_wrap causes debug assert in vector (Kyle Farnung) [#18830](https://github.com/nodejs/node/pull/18830) +* [[`3725d4ccea`](https://github.com/nodejs/node/commit/3725d4ccea)] - **tls**: remove cleartext input data queue (Anna Henningsen) [#17883](https://github.com/nodejs/node/pull/17883) +* [[`aa241eda98`](https://github.com/nodejs/node/commit/aa241eda98)] - **tools**: custom eslint autofix for inspector-check.js (Shobhit Chittora) [#16646](https://github.com/nodejs/node/pull/16646) +* [[`3f865ea6cf`](https://github.com/nodejs/node/commit/3f865ea6cf)] - **tools**: auto fix custom crypto-check eslint rule (Shobhit Chittora) [#16647](https://github.com/nodejs/node/pull/16647) +* [[`ae3398aad6`](https://github.com/nodejs/node/commit/ae3398aad6)] - **tools**: fix eslint isRequired (Ruben Bridgewater) [#18729](https://github.com/nodejs/node/pull/18729) +* [[`a33dc81b2f`](https://github.com/nodejs/node/commit/a33dc81b2f)] - **tools**: add fixer for prefer-assert-iferror.js (Shobhit Chittora) [#16648](https://github.com/nodejs/node/pull/16648) +* [[`aabbdc84c2`](https://github.com/nodejs/node/commit/aabbdc84c2)] - **tools**: add .mjs linting for Windows (Vse Mozhet Byt) [#18569](https://github.com/nodejs/node/pull/18569) +* [[`e00bb1657f`](https://github.com/nodejs/node/commit/e00bb1657f)] - **tools**: non-Ascii linter for /lib only (Sarat Addepalli) [#18043](https://github.com/nodejs/node/pull/18043) +* [[`4f4bfbecbf`](https://github.com/nodejs/node/commit/4f4bfbecbf)] - **tools**: auto fix custom eslint rule (Shobhit Chittora) [#16652](https://github.com/nodejs/node/pull/16652) +* [[`ef45bb4305`](https://github.com/nodejs/node/commit/ef45bb4305)] - **tools**: fix icu readme lint error (Anatoli Papirovski) [#18445](https://github.com/nodejs/node/pull/18445) +* [[`1767ef06f3`](https://github.com/nodejs/node/commit/1767ef06f3)] - **url**: simplify constructor URLSearchParams. Remove needless check null (Mihail Bodrov) [#18700](https://github.com/nodejs/node/pull/18700) +* [[`07e4ba2519`](https://github.com/nodejs/node/commit/07e4ba2519)] - **url**: simplify loop in parser (Tobias Nießen) [#18468](https://github.com/nodejs/node/pull/18468) +* [[`c8f729f7a3`](https://github.com/nodejs/node/commit/c8f729f7a3)] - **v8**: add missing ',' in OpenBSD's 'sources' section. (Aaron Bieber) [#18448](https://github.com/nodejs/node/pull/18448) +* [[`02afdbc5c6`](https://github.com/nodejs/node/commit/02afdbc5c6)] - **vm**: flip Module#link's signature (Gus Caplan) [#18471](https://github.com/nodejs/node/pull/18471) +* [[`1cbd76a100`](https://github.com/nodejs/node/commit/1cbd76a100)] - **vm**: add modules (Gus Caplan) [#17560](https://github.com/nodejs/node/pull/17560) +* [[`c34e2f4fc5`](https://github.com/nodejs/node/commit/c34e2f4fc5)] - **win, build**: fix intl-none option (Birunthan Mohanathas) [#18292](https://github.com/nodejs/node/pull/18292) + ## 2018-01-31, Version 9.5.0 (Current), @evanlucas From 0a262803882adcdcd8dad8a80153e434206290fa Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Tue, 20 Feb 2018 13:26:04 -0500 Subject: [PATCH 46/47] test: really test the ttywrap bits of getasyncid Follow-up from https://github.com/nodejs/node/pull/18800 Code that tries to exercise tty fds must be placed in `/pseudo-tty/`. PR-URL: https://github.com/nodejs/node/pull/18886 Reviewed-By: Ruben Bridgewater --- .../test-async-wrap-getasyncid-tty.js | 43 ++++++++++++++++ .../test-async-wrap-getasyncid-tty.out | 0 test/sequential/test-async-wrap-getasyncid.js | 50 +++---------------- 3 files changed, 51 insertions(+), 42 deletions(-) create mode 100644 test/pseudo-tty/test-async-wrap-getasyncid-tty.js create mode 100644 test/pseudo-tty/test-async-wrap-getasyncid-tty.out diff --git a/test/pseudo-tty/test-async-wrap-getasyncid-tty.js b/test/pseudo-tty/test-async-wrap-getasyncid-tty.js new file mode 100644 index 00000000000..d931a7fdb06 --- /dev/null +++ b/test/pseudo-tty/test-async-wrap-getasyncid-tty.js @@ -0,0 +1,43 @@ +'use strict'; + +// see also test/sequential/test-async-wrap-getasyncid.js + +const common = require('../common'); +const assert = require('assert'); +const tty_wrap = process.binding('tty_wrap'); +const { TTYWRAP } = process.binding('async_wrap').Providers; +const providers = { TTYWRAP }; + +// Make sure that the TTYWRAP Provider is tested. +{ + const hooks = require('async_hooks').createHook({ + init(id, type) { + if (type === 'NONE') + throw new Error('received a provider type of NONE'); + delete providers[type]; + }, + }).enable(); + process.on('beforeExit', common.mustCall(() => { + process.removeAllListeners('uncaughtException'); + hooks.disable(); + + const objKeys = Object.keys(providers); + if (objKeys.length > 0) + process._rawDebug(objKeys); + assert.strictEqual(objKeys.length, 0); + })); +} + +function testInitialized(req, ctor_name) { + assert.strictEqual(typeof req.getAsyncId, 'function'); + assert(Number.isSafeInteger(req.getAsyncId())); + assert(req.getAsyncId() > 0); + assert.strictEqual(req.constructor.name, ctor_name); +} + +{ + const ttyFd = common.getTTYfd(); + + const handle = new tty_wrap.TTY(ttyFd, false); + testInitialized(handle, 'TTY'); +} diff --git a/test/pseudo-tty/test-async-wrap-getasyncid-tty.out b/test/pseudo-tty/test-async-wrap-getasyncid-tty.out new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/sequential/test-async-wrap-getasyncid.js b/test/sequential/test-async-wrap-getasyncid.js index ce9465d94af..bb0ad3d0ef4 100644 --- a/test/sequential/test-async-wrap-getasyncid.js +++ b/test/sequential/test-async-wrap-getasyncid.js @@ -26,16 +26,20 @@ common.crashOnUnhandledRejection(); hooks.disable(); delete providers.NONE; // Should never be used. + // See test/pseudo-tty/test-async-wrap-getasyncid-tty.js + // Requires an 'actual' tty fd to be available. + delete providers.TTYWRAP; + // TODO(jasnell): Test for these delete providers.HTTP2SESSION; delete providers.HTTP2STREAM; delete providers.HTTP2PING; delete providers.HTTP2SETTINGS; - const obj_keys = Object.keys(providers); - if (obj_keys.length > 0) - process._rawDebug(obj_keys); - assert.strictEqual(obj_keys.length, 0); + const objKeys = Object.keys(providers); + if (objKeys.length > 0) + process._rawDebug(objKeys); + assert.strictEqual(objKeys.length, 0); })); } @@ -256,44 +260,6 @@ if (common.hasCrypto) { // eslint-disable-line node-core/crypto-check tls_wrap.wrap(tcp._externalStream, credentials.context, true), 'TLSWrap'); } - -{ - // Do our best to grab a tty fd. - function getTTYfd() { - const tty = require('tty'); - let ttyFd = [0, 1, 2].find(tty.isatty); - if (ttyFd === undefined) { - try { - ttyFd = fs.openSync('/dev/tty'); - } catch (e) { - // There aren't any tty fd's available to use. - return -1; - } - } - return ttyFd; - } - - const ttyFd = getTTYfd(); - if (ttyFd >= 0) { - const tty_wrap = process.binding('tty_wrap'); - // fd may still be invalid, so guard against it. - const handle = (() => { - try { - return new tty_wrap.TTY(ttyFd, false); - } catch (e) { - return null; - } - })(); - if (handle !== null) - testInitialized(handle, 'TTY'); - else - delete providers.TTYWRAP; - } else { - delete providers.TTYWRAP; - } -} - - { const binding = process.binding('udp_wrap'); const handle = new binding.UDP(); From fecc64d6dc905ce1fcc9c8635c653e4a69a2bfc0 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Thu, 22 Feb 2018 17:25:46 +0000 Subject: [PATCH 47/47] test: fix test-http-connect Fixes: https://github.com/nodejs/node/issues/18940 PR-URL: https://github.com/nodejs/node/pull/18941 Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- test/parallel/test-http-connect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-http-connect.js b/test/parallel/test-http-connect.js index f90d235521a..7f163c24821 100644 --- a/test/parallel/test-http-connect.js +++ b/test/parallel/test-http-connect.js @@ -34,7 +34,7 @@ server.on('connect', common.mustCall((req, socket, firstBodyChunk) => { assert.strictEqual(socket.listeners('close').length, 0); assert.strictEqual(socket.listeners('drain').length, 0); assert.strictEqual(socket.listeners('data').length, 0); - assert.strictEqual(socket.listeners('end').length, 1); + assert.strictEqual(socket.listeners('end').length, 2); assert.strictEqual(socket.listeners('error').length, 0); socket.write('HTTP/1.1 200 Connection established\r\n\r\n');