From 3516f35b77fa232a40da267926e3ea53b4f55494 Mon Sep 17 00:00:00 2001 From: Cristian Cavalli Date: Wed, 18 Jan 2017 08:21:02 -0800 Subject: [PATCH 001/148] deps: backport 7c3748a from upstream V8 Original commit message: [debug] load correct stack slot for frame details. R=bmeurer@chromium.org BUG=v8:5071 Review URL: https://codereview.chromium.org/2045863002 . Cr-Commit-Position: refs/heads/master@{#36769} PR-URL: https://github.com/nodejs/node/pull/10873 Reviewed-By: bnoordhuis - Ben Noordhuis Reviewed-By: jasnell - James M Snell Reviewed-By: ofrobots - Ali Ijaz Sheikh --- deps/v8/include/v8-version.h | 2 +- deps/v8/src/runtime/runtime-debug.cc | 3 ++- deps/v8/test/mjsunit/regress/regress-5071.js | 27 ++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 deps/v8/test/mjsunit/regress/regress-5071.js diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 89cf41c1f70d52..fc3292b05ff939 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 4 #define V8_MINOR_VERSION 5 #define V8_BUILD_NUMBER 103 -#define V8_PATCH_LEVEL 45 +#define V8_PATCH_LEVEL 46 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/runtime/runtime-debug.cc b/deps/v8/src/runtime/runtime-debug.cc index e7aaed1f6fbed7..adc2449c4559e1 100644 --- a/deps/v8/src/runtime/runtime-debug.cc +++ b/deps/v8/src/runtime/runtime-debug.cc @@ -670,7 +670,8 @@ RUNTIME_FUNCTION(Runtime_GetFrameDetails) { // Use the value from the stack. if (scope_info->LocalIsSynthetic(i)) continue; locals->set(local * 2, scope_info->LocalName(i)); - locals->set(local * 2 + 1, frame_inspector.GetExpression(i)); + locals->set(local * 2 + 1, + frame_inspector.GetExpression(scope_info->StackLocalIndex(i))); local++; } if (local < local_count) { diff --git a/deps/v8/test/mjsunit/regress/regress-5071.js b/deps/v8/test/mjsunit/regress/regress-5071.js new file mode 100644 index 00000000000000..c69d8a78f2c2e3 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5071.js @@ -0,0 +1,27 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-debug-as debug + +'use strict'; +var Debug = debug.Debug; + +function listener(event, exec_state, event_data, data) { + assertEquals(2, exec_state.frameCount()); + assertEquals("a", exec_state.frame(0).localName(0)); + assertEquals("1", exec_state.frame(0).localValue(0).value()); + assertEquals(1, exec_state.frame(0).localCount()); +} + +Debug.setListener(listener); + +function f() { + var a = 1; + { + let b = 2; + debugger; + } +} + +f(); From e0dc0ceb371f56ff3228f9f11350488ccddcfb08 Mon Sep 17 00:00:00 2001 From: Stewart X Addison Date: Fri, 30 Dec 2016 12:44:46 +0000 Subject: [PATCH 002/148] build: don't squash signal handlers with --shared An application using node built as a shared library may legitimately implement its own signal handling routines. Current behaviour is to squash all signal handlers on node startup. This change will stop that behaviour when node is built as a shared library. PR-URL: https://github.com/nodejs/node/pull/10539 Fixes: https://github.com/nodejs/node/issues/10520 Refs: https://github.com/nodejs/node/pull/615 Reviewed-By: Sam Roberts Reviewed-By: Gibson Fahnestock Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis --- src/node.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/node.cc b/src/node.cc index 3b0837b1c1eafe..6c98a9b70b1ea0 100644 --- a/src/node.cc +++ b/src/node.cc @@ -3957,6 +3957,7 @@ inline void PlatformInit() { CHECK_EQ(err, 0); +#ifndef NODE_SHARED_MODE // Restore signal dispositions, the parent process may have changed them. struct sigaction act; memset(&act, 0, sizeof(act)); @@ -3970,6 +3971,7 @@ inline void PlatformInit() { act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL; CHECK_EQ(0, sigaction(nr, &act, nullptr)); } +#endif // !NODE_SHARED_MODE RegisterSignalHandler(SIGINT, SignalExit, true); RegisterSignalHandler(SIGTERM, SignalExit, true); From 35a660ee7089fe44fe58334692d3f466957f5196 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Sun, 30 Oct 2016 13:22:50 -0700 Subject: [PATCH 003/148] crypto: fix handling of root_cert_store. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SecureContext::AddRootCerts only parses the root certificates once and keeps the result in root_cert_store, a global X509_STORE. This change addresses the following issues: 1. SecureContext::AddCACert would add certificates to whatever X509_STORE was being used, even if that happened to be root_cert_store. Thus adding a CA certificate to a SecureContext would also cause it to be included in unrelated SecureContexts. 2. AddCRL would crash if neither AddRootCerts nor AddCACert had been called first. 3. Calling AddCACert without calling AddRootCerts first, and with an input that didn't contain any certificates, would leak an X509_STORE. 4. AddCRL would add the CRL to whatever X509_STORE was being used. Thus, like AddCACert, unrelated SecureContext objects could be affected. The following, non-obvious behaviour remains: calling AddRootCerts doesn't /add/ them, rather it sets the CA certs to be the root set and overrides any previous CA certificates. Points 1–3 are probably unimportant because the SecureContext is typically configured by `createSecureContext` in `lib/_tls_common.js`. This function either calls AddCACert or AddRootCerts and only calls AddCRL after setting up CA certificates. Point four could still apply in the unlikely case that someone configures a CRL without explicitly configuring the CAs. PR-URL: https://github.com/nodejs/node/pull/9409 Reviewed-By: Fedor Indutny Reviewed-By: Shigeki Ohtsu --- src/node_crypto.cc | 135 ++++++++++++++++++++------------ src/node_crypto.h | 27 +++---- test/parallel/test-crypto.js | 4 + test/parallel/test-tls-addca.js | 62 +++++++++++++++ 4 files changed, 162 insertions(+), 66 deletions(-) create mode 100644 test/parallel/test-tls-addca.js diff --git a/src/node_crypto.cc b/src/node_crypto.cc index e58b0bc25bb65b..7e351d6b75499c 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -123,6 +123,7 @@ const char* const root_certs[] = { std::string extra_root_certs_file; // NOLINT(runtime/string) X509_STORE* root_cert_store; +std::vector* root_certs_vector; // Just to generate static methods template class SSLWrap; @@ -404,8 +405,6 @@ void SecureContext::Init(const FunctionCallbackInfo& args) { SSL_SESS_CACHE_NO_AUTO_CLEAR); SSL_CTX_sess_set_get_cb(sc->ctx_, SSLWrap::GetSessionCallback); SSL_CTX_sess_set_new_cb(sc->ctx_, SSLWrap::NewSessionCallback); - - sc->ca_store_ = nullptr; } @@ -689,8 +688,52 @@ void SecureContext::SetCert(const FunctionCallbackInfo& args) { } +#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL) +// This section contains OpenSSL 1.1.0 functions reimplemented for OpenSSL +// 1.0.2 so that the following code can be written without lots of #if lines. + +static int X509_STORE_up_ref(X509_STORE* store) { + CRYPTO_add(&store->references, 1, CRYPTO_LOCK_X509_STORE); + return 1; +} + +static int X509_up_ref(X509* cert) { + CRYPTO_add(&cert->references, 1, CRYPTO_LOCK_X509); + return 1; +} +#endif // OPENSSL_VERSION_NUMBER < 0x10100000L && !OPENSSL_IS_BORINGSSL + + +static X509_STORE* NewRootCertStore() { + if (!root_certs_vector) { + root_certs_vector = new std::vector; + + for (size_t i = 0; i < arraysize(root_certs); i++) { + BIO* bp = NodeBIO::NewFixed(root_certs[i], strlen(root_certs[i])); + X509 *x509 = PEM_read_bio_X509(bp, nullptr, CryptoPemCallback, nullptr); + BIO_free(bp); + + if (x509 == nullptr) { + // Parse errors from the built-in roots are fatal. + abort(); + return nullptr; + } + + root_certs_vector->push_back(x509); + } + } + + X509_STORE* store = X509_STORE_new(); + for (auto& cert : *root_certs_vector) { + X509_up_ref(cert); + X509_STORE_add_cert(store, cert); + } + + return store; +} + + void SecureContext::AddCACert(const FunctionCallbackInfo& args) { - bool newCAStore = false; Environment* env = Environment::GetCurrent(args); SecureContext* sc; @@ -702,23 +745,24 @@ void SecureContext::AddCACert(const FunctionCallbackInfo& args) { return env->ThrowTypeError("Bad parameter"); } - if (!sc->ca_store_) { - sc->ca_store_ = X509_STORE_new(); - newCAStore = true; - } - - X509* x509 = LoadX509(env, args[0]); - if (!x509) + BIO* bio = LoadBIO(env, args[0]); + if (!bio) { return; + } - X509_STORE_add_cert(sc->ca_store_, x509); - SSL_CTX_add_client_CA(sc->ctx_, x509); - - X509_free(x509); - - if (newCAStore) { - SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_); + X509_STORE* cert_store = SSL_CTX_get_cert_store(sc->ctx_); + while (X509* x509 = + PEM_read_bio_X509(bio, nullptr, CryptoPemCallback, nullptr)) { + if (cert_store == root_cert_store) { + cert_store = NewRootCertStore(); + SSL_CTX_set_cert_store(sc->ctx_, cert_store); + } + X509_STORE_add_cert(cert_store, x509); + SSL_CTX_add_client_CA(sc->ctx_, x509); + X509_free(x509); } + + BIO_free_all(bio); } @@ -739,19 +783,27 @@ void SecureContext::AddCRL(const FunctionCallbackInfo& args) { if (!bio) return; - X509_CRL *x509 = + X509_CRL* crl = PEM_read_bio_X509_CRL(bio, nullptr, CryptoPemCallback, nullptr); - if (x509 == nullptr) { + if (crl == nullptr) { + return env->ThrowError("Failed to parse CRL"); BIO_free_all(bio); return; } - X509_STORE_add_crl(sc->ca_store_, x509); - X509_STORE_set_flags(sc->ca_store_, X509_V_FLAG_CRL_CHECK | - X509_V_FLAG_CRL_CHECK_ALL); + X509_STORE* cert_store = SSL_CTX_get_cert_store(sc->ctx_); + if (cert_store == root_cert_store) { + cert_store = NewRootCertStore(); + SSL_CTX_set_cert_store(sc->ctx_, cert_store); + } + + X509_STORE_add_crl(cert_store, crl); + X509_STORE_set_flags(cert_store, + X509_V_FLAG_CRL_CHECK | X509_V_FLAG_CRL_CHECK_ALL); + BIO_free_all(bio); - X509_CRL_free(x509); + X509_CRL_free(crl); } @@ -794,28 +846,8 @@ void SecureContext::AddRootCerts(const FunctionCallbackInfo& args) { ClearErrorOnReturn clear_error_on_return; (void) &clear_error_on_return; // Silence compiler warning. - CHECK_EQ(sc->ca_store_, nullptr); - if (!root_cert_store) { - root_cert_store = X509_STORE_new(); - - for (size_t i = 0; i < arraysize(root_certs); i++) { - BIO* bp = NodeBIO::NewFixed(root_certs[i], strlen(root_certs[i])); - if (bp == nullptr) { - return; - } - - X509 *x509 = PEM_read_bio_X509(bp, nullptr, CryptoPemCallback, nullptr); - if (x509 == nullptr) { - BIO_free_all(bp); - return; - } - - X509_STORE_add_cert(root_cert_store, x509); - - BIO_free_all(bp); - X509_free(x509); - } + root_cert_store = NewRootCertStore(); if (!extra_root_certs_file.empty()) { unsigned long err = AddCertsFromFile( // NOLINT(runtime/int) @@ -830,10 +862,9 @@ void SecureContext::AddRootCerts(const FunctionCallbackInfo& args) { } } - sc->ca_store_ = root_cert_store; // Increment reference count so global store is not deleted along with CTX. - CRYPTO_add(&root_cert_store->references, 1, CRYPTO_LOCK_X509_STORE); - SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_); + X509_STORE_up_ref(root_cert_store); + SSL_CTX_set_cert_store(sc->ctx_, root_cert_store); } @@ -1034,6 +1065,8 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo& args) { sc->cert_ = nullptr; } + X509_STORE* cert_store = SSL_CTX_get_cert_store(sc->ctx_); + if (d2i_PKCS12_bio(in, &p12) && PKCS12_parse(p12, pass, &pkey, &cert, &extra_certs) && SSL_CTX_use_certificate_chain(sc->ctx_, @@ -1046,11 +1079,11 @@ void SecureContext::LoadPKCS12(const FunctionCallbackInfo& args) { for (int i = 0; i < sk_X509_num(extra_certs); i++) { X509* ca = sk_X509_value(extra_certs, i); - if (!sc->ca_store_) { - sc->ca_store_ = X509_STORE_new(); - SSL_CTX_set_cert_store(sc->ctx_, sc->ca_store_); + if (cert_store == root_cert_store) { + cert_store = NewRootCertStore(); + SSL_CTX_set_cert_store(sc->ctx_, cert_store); } - X509_STORE_add_cert(sc->ca_store_, ca); + X509_STORE_add_cert(cert_store, ca); SSL_CTX_add_client_CA(sc->ctx_, ca); } ret = true; diff --git a/src/node_crypto.h b/src/node_crypto.h index 9a4d936f305ee1..f09ce3e7cab520 100644 --- a/src/node_crypto.h +++ b/src/node_crypto.h @@ -76,7 +76,6 @@ class SecureContext : public BaseObject { static void Initialize(Environment* env, v8::Local target); - X509_STORE* ca_store_; SSL_CTX* ctx_; X509* cert_; X509* issuer_; @@ -131,7 +130,6 @@ class SecureContext : public BaseObject { SecureContext(Environment* env, v8::Local wrap) : BaseObject(env, wrap), - ca_store_(nullptr), ctx_(nullptr), cert_(nullptr), issuer_(nullptr) { @@ -140,20 +138,19 @@ class SecureContext : public BaseObject { } void FreeCTXMem() { - if (ctx_) { - env()->isolate()->AdjustAmountOfExternalAllocatedMemory(-kExternalSize); - SSL_CTX_free(ctx_); - if (cert_ != nullptr) - X509_free(cert_); - if (issuer_ != nullptr) - X509_free(issuer_); - ctx_ = nullptr; - ca_store_ = nullptr; - cert_ = nullptr; - issuer_ = nullptr; - } else { - CHECK_EQ(ca_store_, nullptr); + if (!ctx_) { + return; } + + env()->isolate()->AdjustAmountOfExternalAllocatedMemory(-kExternalSize); + SSL_CTX_free(ctx_); + if (cert_ != nullptr) + X509_free(cert_); + if (issuer_ != nullptr) + X509_free(issuer_); + ctx_ = nullptr; + cert_ = nullptr; + issuer_ = nullptr; } }; diff --git a/test/parallel/test-crypto.js b/test/parallel/test-crypto.js index a325ee131cbb2e..0cbb46ea8f2a63 100644 --- a/test/parallel/test-crypto.js +++ b/test/parallel/test-crypto.js @@ -140,3 +140,7 @@ assert.throws(function() { // Make sure memory isn't released before being returned console.log(crypto.randomBytes(16)); + +assert.throws(function() { + tls.createSecureContext({ crl: 'not a CRL' }); +}, /Failed to parse CRL/); diff --git a/test/parallel/test-tls-addca.js b/test/parallel/test-tls-addca.js new file mode 100644 index 00000000000000..0e9571efdf0abf --- /dev/null +++ b/test/parallel/test-tls-addca.js @@ -0,0 +1,62 @@ +'use strict'; +const common = require('../common'); +const fs = require('fs'); + +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} +const tls = require('tls'); + +function filenamePEM(n) { + return require('path').join(common.fixturesDir, 'keys', n + '.pem'); +} + +function loadPEM(n) { + return fs.readFileSync(filenamePEM(n)); +} + +const caCert = loadPEM('ca1-cert'); +const contextWithoutCert = tls.createSecureContext({}); +const contextWithCert = tls.createSecureContext({}); +// Adding a CA certificate to contextWithCert should not also add it to +// contextWithoutCert. This is tested by trying to connect to a server that +// depends on that CA using contextWithoutCert. +contextWithCert.context.addCACert(caCert); + +const serverOptions = { + key: loadPEM('agent1-key'), + cert: loadPEM('agent1-cert'), +}; +const server = tls.createServer(serverOptions, function() {}); + +const clientOptions = { + port: undefined, + ca: [caCert], + servername: 'agent1', + rejectUnauthorized: true, +}; + +function startTest() { + // This client should fail to connect because it doesn't trust the CA + // certificate. + clientOptions.secureContext = contextWithoutCert; + clientOptions.port = server.address().port; + const client = tls.connect(clientOptions, common.fail); + client.on('error', common.mustCall(() => { + client.destroy(); + + // This time it should connect because contextWithCert includes the needed + // CA certificate. + clientOptions.secureContext = contextWithCert; + const client2 = tls.connect(clientOptions, common.mustCall(() => { + client2.destroy(); + server.close(); + })); + client2.on('error', (e) => { + console.log(e); + }); + })); +} + +server.listen(0, startTest); From a9eb093ce37688c1a308e9733062cb506ce2c2a6 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 14 Nov 2016 13:39:40 +0100 Subject: [PATCH 004/148] src: fix memory leak introduced in 34febfbf4 Fix leaking the BIO in the error path. Introduced in commit 34febfbf4 ("crypto: fix handling of root_cert_store"). PR-URL: https://github.com/nodejs/node/pull/9604 Refs: https://github.com/nodejs/node/pull/9409 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Fedor Indutny Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel Reviewed-By: Michael Dawson Reviewed-By: Rod Vagg --- src/node_crypto.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 7e351d6b75499c..c5f5871617c222 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -787,9 +787,8 @@ void SecureContext::AddCRL(const FunctionCallbackInfo& args) { PEM_read_bio_X509_CRL(bio, nullptr, CryptoPemCallback, nullptr); if (crl == nullptr) { - return env->ThrowError("Failed to parse CRL"); BIO_free_all(bio); - return; + return env->ThrowError("Failed to parse CRL"); } X509_STORE* cert_store = SSL_CTX_get_cert_store(sc->ctx_); From 2f480015741223b10de56e1ac74ec0327dc2b636 Mon Sep 17 00:00:00 2001 From: Evan Lucas Date: Tue, 15 Nov 2016 05:29:38 -0600 Subject: [PATCH 005/148] src: use ABORT() macro instead of abort() This makes sure that we dump a backtrace and use raise(SIGABRT) on Windows. PR-URL: https://github.com/nodejs/node/pull/9613 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig --- src/node_crypto.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index c5f5871617c222..2573035d9efb8f 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -715,7 +715,7 @@ static X509_STORE* NewRootCertStore() { if (x509 == nullptr) { // Parse errors from the built-in roots are fatal. - abort(); + ABORT(); return nullptr; } From b48f6ffc637a10dd526cd926425f9706e4757835 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Thu, 22 Dec 2016 08:50:33 -0800 Subject: [PATCH 006/148] crypto: use CHECK_NE instead of ABORT or abort Use of abort() was added in 34febfbf4, and changed to ABORT() in 21826ef21ad, but conditional+ABORT() is better expressesed using a CHECK_xxx() macro. See: https://github.com/nodejs/node/pull/9409#discussion_r93575328 PR-URL: https://github.com/nodejs/node/pull/10413 Reviewed-By: Colin Ihrig Reviewed-By: Gibson Fahnestock Reviewed-By: Ben Noordhuis Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- src/node_crypto.cc | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 2573035d9efb8f..b06c1d698be8c1 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -713,11 +713,8 @@ static X509_STORE* NewRootCertStore() { X509 *x509 = PEM_read_bio_X509(bp, nullptr, CryptoPemCallback, nullptr); BIO_free(bp); - if (x509 == nullptr) { - // Parse errors from the built-in roots are fatal. - ABORT(); - return nullptr; - } + // Parse errors from the built-in roots are fatal. + CHECK_NE(x509, nullptr); root_certs_vector->push_back(x509); } From 4ce9bfb4e7eeb2f651d307b42e7fdbb255a2c0d6 Mon Sep 17 00:00:00 2001 From: Gireesh Punathil Date: Tue, 28 Feb 2017 06:51:05 -0500 Subject: [PATCH 007/148] test: exclude pseudo-tty test pertinent to #11541 This test is newly added to v4.x stream and is consistently failing. We have a couple of issues with pseudo-tty tests in AIX, and while the investigation is going on, need to skip this test to make CI green. PR-URL: https://github.com/nodejs/node/pull/11602 Reviewed-By: Gibson Fahnestock Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: Myles Borins --- test/pseudo-tty/pseudo-tty.status | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/pseudo-tty/pseudo-tty.status b/test/pseudo-tty/pseudo-tty.status index e16bb28cd7be61..83e6d05a4c2e20 100644 --- a/test/pseudo-tty/pseudo-tty.status +++ b/test/pseudo-tty/pseudo-tty.status @@ -2,5 +2,7 @@ prefix pseudo-tty [$system==aix] # test issue only, covered under https://github.com/nodejs/node/issues/7973 -no_dropped_stdio : SKIP -no_interleaved_stdio : SKIP +no_dropped_stdio : SKIP +no_interleaved_stdio : SKIP +# test issue: https://github.com/nodejs/node/issues/11541 +test-stderr-stdout-handle-sigwinch : SKIP From 15231aa6e56d64813994e04293e5adaeba24d0b8 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 4 Oct 2016 11:44:54 +0200 Subject: [PATCH 008/148] http: reject control characters in http.request() Unsanitized paths containing line feed characters can be used for header injection and request splitting so reject them with an exception. There seems to be no reasonable use case for allowing control characters (characters <= 31) while there are several scenarios where they can be used to exploit software bugs so reject control characters altogether. PR-URL: https://github.com/nodejs/node/pull/8923 Reviewed-By: Anna Henningsen Reviewed-By: Evan Lucas Reviewed-By: Fedor Indutny Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: not-an-aardvark --- lib/_http_client.js | 2 +- .../test-http-client-unescaped-path.js | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/_http_client.js b/lib/_http_client.js index c07589e9c5da6f..26590b9aec2e23 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -40,7 +40,7 @@ function ClientRequest(options, cb) { if (self.agent && self.agent.protocol) expectedProtocol = self.agent.protocol; - if (options.path && / /.test(options.path)) { + if (options.path && /[\u0000-\u0020]/.test(options.path)) { // The actual regex is more like /[^A-Za-z0-9\-._~!$&'()*+,;=/:@]/ // with an additional rule for ignoring percentage-escaped characters // but that's a) hard to capture in a regular expression that performs diff --git a/test/parallel/test-http-client-unescaped-path.js b/test/parallel/test-http-client-unescaped-path.js index e01df255a8042c..2411d0e6be31e2 100644 --- a/test/parallel/test-http-client-unescaped-path.js +++ b/test/parallel/test-http-client-unescaped-path.js @@ -1,9 +1,14 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var http = require('http'); +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); -assert.throws(function() { - // Path with spaces in it should throw. - http.get({ path: 'bad path' }, common.fail); -}, /contains unescaped characters/); +function* bad() { + for (let i = 0; i <= 32; i += 1) + yield 'bad' + String.fromCharCode(i) + 'path'; +} + +for (const path of bad()) { + assert.throws(() => http.get({ path }, common.fail), + /contains unescaped characters/); +} From 536733697cb6fdd86b39d72bee4317badc6918ab Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Thu, 17 Nov 2016 11:20:27 +1100 Subject: [PATCH 009/148] test: simplify test-http-client-unescaped-path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/9649 Reviewed-By: Trevor Norris Reviewed-By: Santiago Gimeno Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: Anna Henningsen --- test/parallel/test-http-client-unescaped-path.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-http-client-unescaped-path.js b/test/parallel/test-http-client-unescaped-path.js index 2411d0e6be31e2..1a74943e838259 100644 --- a/test/parallel/test-http-client-unescaped-path.js +++ b/test/parallel/test-http-client-unescaped-path.js @@ -3,12 +3,8 @@ const common = require('../common'); const assert = require('assert'); const http = require('http'); -function* bad() { - for (let i = 0; i <= 32; i += 1) - yield 'bad' + String.fromCharCode(i) + 'path'; -} - -for (const path of bad()) { +for (let i = 0; i <= 32; i += 1) { + const path = 'bad' + String.fromCharCode(i) + 'path'; assert.throws(() => http.get({ path }, common.fail), /contains unescaped characters/); } From 87db4f722567b741d084730a719fa6c14ddb42ac Mon Sep 17 00:00:00 2001 From: sxa555 Date: Mon, 28 Nov 2016 18:39:47 +0000 Subject: [PATCH 010/148] build: Don't regenerate node symlink The node -> out/*/node symlink is getting recreated in parallel with other targets in the makefile which require it (e.g. test-ci) and this seems to be causing a race condition which is showing up on AIX Fixes: https://github.com/nodejs/node/issues/9825 PR-URL: https://github.com/nodejs/node/pull/9827 Reviewed-By: Gibson Fahnestock Reviewed-By: Ben Noordhuis Reviewed-by: Michael Dawson --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3160f41c41fd3f..205e64c2309a13 100644 --- a/Makefile +++ b/Makefile @@ -60,13 +60,18 @@ endif # to check for changes. .PHONY: $(NODE_EXE) $(NODE_G_EXE) +# The -r/-L check stops it recreating the link if it is already in place, +# otherwise $(NODE_EXE) being a .PHONY target means it is always re-run. +# Without the check there is a race condition between the link being deleted +# and recreated which can break the addons build when running test-ci +# See comments on the build-addons target for some more info $(NODE_EXE): config.gypi out/Makefile $(MAKE) -C out BUILDTYPE=Release V=$(V) - ln -fs out/Release/$(NODE_EXE) $@ + if [ ! -r $(NODE_EXE) -o ! -L $(NODE_EXE) ]; then ln -fs out/Release/$(NODE_EXE) $@; fi $(NODE_G_EXE): config.gypi out/Makefile $(MAKE) -C out BUILDTYPE=Debug V=$(V) - ln -fs out/Debug/$(NODE_EXE) $@ + if [ ! -r $(NODE_EXE) -o ! -L $(node_EXE) ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp deps/zlib/zlib.gyp deps/v8/build/toolchain.gypi deps/v8/build/features.gypi deps/v8/tools/gyp/v8.gyp node.gyp config.gypi $(PYTHON) tools/gyp_node.py -f make From 094bfe66aa5cf4565ea0eb47e4295c18ede42298 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 6 Dec 2016 19:28:47 +0100 Subject: [PATCH 011/148] build: fix node_g target Currently when running make node_g the following error is displayed: if [ ! -r node -o ! -L ]; then ln -fs out/Debug/node node_g; fi /bin/sh: line 0: [: argument expected It looks like there was a typo for the NODE_EXE where node became lowercase instead of uppercase. Ref: https://github.com/nodejs/node/pull/9827 PR-URL: https://github.com/nodejs/node/pull/10153 Reviewed-By: Jeremiah Senkpiel Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Italo A. Casas --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 205e64c2309a13..f9293d6d6c0174 100644 --- a/Makefile +++ b/Makefile @@ -67,11 +67,11 @@ endif # See comments on the build-addons target for some more info $(NODE_EXE): config.gypi out/Makefile $(MAKE) -C out BUILDTYPE=Release V=$(V) - if [ ! -r $(NODE_EXE) -o ! -L $(NODE_EXE) ]; then ln -fs out/Release/$(NODE_EXE) $@; fi + if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Release/$(NODE_EXE) $@; fi $(NODE_G_EXE): config.gypi out/Makefile $(MAKE) -C out BUILDTYPE=Debug V=$(V) - if [ ! -r $(NODE_EXE) -o ! -L $(node_EXE) ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi + if [ ! -r $@ -o ! -L $@ ]; then ln -fs out/Debug/$(NODE_EXE) $@; fi out/Makefile: common.gypi deps/uv/uv.gyp deps/http_parser/http_parser.gyp deps/zlib/zlib.gyp deps/v8/build/toolchain.gypi deps/v8/build/features.gypi deps/v8/tools/gyp/v8.gyp node.gyp config.gypi $(PYTHON) tools/gyp_node.py -f make From 530adfdb2a3357e3b8aa43fbd488bbdff04b5fc0 Mon Sep 17 00:00:00 2001 From: Matt Crummey Date: Thu, 1 Dec 2016 17:59:47 +0000 Subject: [PATCH 012/148] doc: improve rinfo object documentation Provide details for fields of rinfo object of UDP message event. PR-URL: https://github.com/nodejs/node/pull/10050 Reviewed-By: James M Snell --- doc/api/dgram.md | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/doc/api/dgram.md b/doc/api/dgram.md index 92e51b7072aeee..b80289f6c99bdd 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -70,20 +70,14 @@ datagram messages. This occurs as soon as UDP sockets are created. added: v0.1.99 --> +The `'message'` event is emitted when a new datagram is available on a socket. +The event handler function is passed two arguments: `msg` and `rinfo`. * `msg` {Buffer} - The message * `rinfo` {Object} - Remote address information - -The `'message'` event is emitted when a new datagram is available on a socket. -The event handler function is passed two arguments: `msg` and `rinfo`. The -`msg` argument is a [`Buffer`][] and `rinfo` is an object with the sender's -address information provided by the `address`, `family` and `port` properties: - -```js -socket.on('message', (msg, rinfo) => { - console.log('Received %d bytes from %s:%d\n', - msg.length, rinfo.address, rinfo.port); -}); -``` + * `address` {String} The sender address + * `family` {String} The address family (`'IPv4'` or `'IPv6'`) + * `port` {Number} The sender port + * `size` {Number} The message size ### socket.addMembership(multicastAddress[, multicastInterface]) -Compress a Buffer or string with Deflate. +Compress a [Buffer][] or string with [Deflate][]. ### zlib.deflateRaw(buf[, options], callback) -Compress a Buffer or string with DeflateRaw. +Compress a [Buffer][] or string with [DeflateRaw][]. ### zlib.gunzip(buf[, options], callback) -Decompress a Buffer or string with Gunzip. +Decompress a [Buffer][] or string with [Gunzip][]. ### zlib.gzip(buf[, options], callback) -Compress a Buffer or string with Gzip. +Compress a [Buffer][] or string with [Gzip][]. ### zlib.inflate(buf[, options], callback) -Decompress a Buffer or string with Inflate. +Decompress a [Buffer][] or string with [Inflate][]. ### zlib.inflateRaw(buf[, options], callback) -Decompress a Buffer or string with InflateRaw. +Decompress a [Buffer][] or string with [InflateRaw][]. ### zlib.unzip(buf[, options], callback) -Decompress a Buffer or string with Unzip. +Decompress a [Buffer][] or string with [Unzip][]. [accept-encoding]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3 [content-encoding]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 From 6d0e1621e5cf552a7a5894b4582bfcc84cd42efa Mon Sep 17 00:00:00 2001 From: Jessica Quynh Tran Date: Thu, 24 Nov 2016 18:35:15 -0500 Subject: [PATCH 018/148] doc: clarifying variables in fs.write() This commit clarifies variables in the Filesystem docs. Prior, the documentation for fs.write() had an ambiguous remark on the parameters of offset and length. Therefore, this commit makes explicit that the length parameter in fs.write() is used to denote the number of bytes, which is a clearer reference for its usage. PR-URL: https://github.com/nodejs/node/pull/9792 Ref: https://github.com/nodejs/node/issues/7868 Reviewed-By: Sam Roberts --- doc/api/fs.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/api/fs.md b/doc/api/fs.md index 8d934e98340d41..5a604ac765ed08 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1347,7 +1347,8 @@ added: v0.0.2 Write `buffer` to the file specified by `fd`. -`offset` and `length` determine the part of the buffer to be written. +`offset` determines the part of the buffer to be written, and `length` is +an integer specifying the number of bytes to write. `position` refers to the offset from the beginning of the file where this data should be written. If `typeof position !== 'number'`, the data will be written From e656a4244ac650f7bbee8c424ac99faf861e9171 Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Wed, 18 Jan 2017 16:09:36 -0500 Subject: [PATCH 019/148] doc: add edsadr to collaborators PR-URL: https://github.com/nodejs/node/pull/10883 Reviewed-By: Rich Trott Reviewed-By: Luigi Pinca Reviewed-By: Italo A. Casas Reviewed-By: Santiago Gimeno --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3c77d87c06f171..7fdb0c00a74b7f 100644 --- a/README.md +++ b/README.md @@ -219,6 +219,8 @@ more information about the governance of the Node.js project, see **Claudio Rodriguez** <cjrodr@yahoo.com> * [danbev](https://github.com/danbev) - **Daniel Bevenius** <daniel.bevenius@gmail.com> +* [edsadr](https://github.com/edsadr) - +**Adrian Estrada** <edsadr@gmail.com> * [eljefedelrodeodeljefe](https://github.com/eljefedelrodeodeljefe) - **Robert Jefe Lindstaedt** <robert.lindstaedt@gmail.com> * [estliberitas](https://github.com/estliberitas) - From 79f700c891d582819191d54303bf0e390b8bc381 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Sun, 22 Jan 2017 13:28:57 -0800 Subject: [PATCH 020/148] doc: add TimothyGu to collaborators PR-URL: https://github.com/nodejs/node/pull/10954 Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7fdb0c00a74b7f..59aa20d8e8bce1 100644 --- a/README.md +++ b/README.md @@ -329,6 +329,8 @@ more information about the governance of the Node.js project, see **Glen Keane** <glenkeane.94@gmail.com> * [thlorenz](https://github.com/thlorenz) - **Thorsten Lorenz** <thlorenz@gmx.de> +* [TimothyGu](https://github.com/TimothyGu) - +**Timothy Gu** <timothygu99@gmail.com> * [tunniclm](https://github.com/tunniclm) - **Mike Tunnicliffe** <m.j.tunnicliffe@gmail.com> * [vkurchatkin](https://github.com/vkurchatkin) - From 05273c5a4ecab26f7e41e426931aeaff1030e588 Mon Sep 17 00:00:00 2001 From: Noah Rose Ledesma Date: Sat, 21 Jan 2017 16:19:22 -0800 Subject: [PATCH 021/148] doc: update AUTHORS list to fix name Changed authors listing from `Noah Rose` to `Noah Rose Ledesma`. PR-URL: https://github.com/nodejs/node/pull/10945 Reviewed-By: Rich Trott Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 0f49f0b7dd1887..a3ca4567bb8c0f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -935,7 +935,7 @@ Felix Becker Igor Klopov Tsarevich Dmitry Ojas Shirekar -Noah Rose +Noah Rose Ledesma Rafael Cepeda Chinedu Francis Nwafili Braydon Fuller From 0109321fd8901dbdcfdfb0907f19bf228b7c2030 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 10 Dec 2016 21:12:58 -0800 Subject: [PATCH 022/148] test: refactor test-https-truncate * use common.mustCall() where appropriate * Buffer.allocUnsafe() -> Buffer.alloc() * do crypto check before loading any additional modules * specify 1ms duration for `setTimeout()` PR-URL: https://github.com/nodejs/node/pull/10225 Reviewed-By: Colin Ihrig Reviewed-By: Benjamin Gruenbaum Reviewed-By: Luigi Pinca --- test/parallel/test-https-truncate.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-https-truncate.js b/test/parallel/test-https-truncate.js index 4101a8c974e736..c96b385fc37fde 100644 --- a/test/parallel/test-https-truncate.js +++ b/test/parallel/test-https-truncate.js @@ -1,11 +1,12 @@ 'use strict'; const common = require('../common'); -const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } + +const assert = require('assert'); const https = require('https'); const fs = require('fs'); @@ -14,7 +15,7 @@ const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); // number of bytes discovered empirically to trigger the bug -const data = Buffer.allocUnsafe(1024 * 32 + 1); +const data = Buffer.alloc(1024 * 32 + 1); httpsTest(); @@ -36,12 +37,11 @@ function httpsTest() { } -function test(res) { - res.on('end', function() { +const test = common.mustCall(function(res) { + res.on('end', common.mustCall(function() { assert.strictEqual(res._readableState.length, 0); assert.strictEqual(bytes, data.length); - console.log('ok'); - }); + })); // Pause and then resume on each chunk, to ensure that there will be // a lone byte hanging out at the very end. @@ -49,6 +49,6 @@ function test(res) { res.on('data', function(chunk) { bytes += chunk.length; this.pause(); - setTimeout(this.resume.bind(this)); + setTimeout(this.resume.bind(this), 1); }); -} +}); From fc2cd63998f8b304aa142c4fd738b8f55d3f8b21 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 9 Dec 2016 00:17:14 +0100 Subject: [PATCH 023/148] lib,src: support values > 4GB in heap statistics We were transporting the heap statistics as uint32 values to JS land but those wrap around for values > 4 GB. Use 64 bits floats instead, those should last us a while. Fixes: https://github.com/nodejs/node/issues/10185 PR-URL: https://github.com/nodejs/node/pull/10186 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Evan Lucas --- lib/v8.js | 4 ++-- src/env-inl.h | 8 ++++---- src/env.h | 12 ++++++------ src/node_v8.cc | 12 ++++++------ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/lib/v8.js b/lib/v8.js index e78a2480ff04e7..c1ca09dda8bb07 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -18,7 +18,7 @@ const v8binding = process.binding('v8'); // Properties for heap statistics buffer extraction. const heapStatisticsBuffer = - new Uint32Array(v8binding.heapStatisticsArrayBuffer); + new Float64Array(v8binding.heapStatisticsArrayBuffer); const kTotalHeapSizeIndex = v8binding.kTotalHeapSizeIndex; const kTotalHeapSizeExecutableIndex = v8binding.kTotalHeapSizeExecutableIndex; const kTotalPhysicalSizeIndex = v8binding.kTotalPhysicalSizeIndex; @@ -28,7 +28,7 @@ const kHeapSizeLimitIndex = v8binding.kHeapSizeLimitIndex; // Properties for heap space statistics buffer extraction. const heapSpaceStatisticsBuffer = - new Uint32Array(v8binding.heapSpaceStatisticsArrayBuffer); + new Float64Array(v8binding.heapSpaceStatisticsArrayBuffer); const kHeapSpaces = v8binding.kHeapSpaces; const kNumberOfHeapSpaces = kHeapSpaces.length; const kHeapSpaceStatisticsPropertiesCount = diff --git a/src/env-inl.h b/src/env-inl.h index 29be9c86ac4c56..9121767a99b966 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -378,22 +378,22 @@ inline std::vector* Environment::destroy_ids_list() { return &destroy_ids_list_; } -inline uint32_t* Environment::heap_statistics_buffer() const { +inline double* Environment::heap_statistics_buffer() const { CHECK_NE(heap_statistics_buffer_, nullptr); return heap_statistics_buffer_; } -inline void Environment::set_heap_statistics_buffer(uint32_t* pointer) { +inline void Environment::set_heap_statistics_buffer(double* pointer) { CHECK_EQ(heap_statistics_buffer_, nullptr); // Should be set only once. heap_statistics_buffer_ = pointer; } -inline uint32_t* Environment::heap_space_statistics_buffer() const { +inline double* Environment::heap_space_statistics_buffer() const { CHECK_NE(heap_space_statistics_buffer_, nullptr); return heap_space_statistics_buffer_; } -inline void Environment::set_heap_space_statistics_buffer(uint32_t* pointer) { +inline void Environment::set_heap_space_statistics_buffer(double* pointer) { CHECK_EQ(heap_space_statistics_buffer_, nullptr); // Should be set only once. heap_space_statistics_buffer_ = pointer; } diff --git a/src/env.h b/src/env.h index fffb816d80608f..fa064e42261141 100644 --- a/src/env.h +++ b/src/env.h @@ -462,11 +462,11 @@ class Environment { // List of id's that have been destroyed and need the destroy() cb called. inline std::vector* destroy_ids_list(); - inline uint32_t* heap_statistics_buffer() const; - inline void set_heap_statistics_buffer(uint32_t* pointer); + inline double* heap_statistics_buffer() const; + inline void set_heap_statistics_buffer(double* pointer); - inline uint32_t* heap_space_statistics_buffer() const; - inline void set_heap_space_statistics_buffer(uint32_t* pointer); + inline double* heap_space_statistics_buffer() const; + inline void set_heap_space_statistics_buffer(double* pointer); inline char* http_parser_buffer() const; inline void set_http_parser_buffer(char* buffer); @@ -570,8 +570,8 @@ class Environment { &HandleCleanup::handle_cleanup_queue_> handle_cleanup_queue_; int handle_cleanup_waiting_; - uint32_t* heap_statistics_buffer_ = nullptr; - uint32_t* heap_space_statistics_buffer_ = nullptr; + double* heap_statistics_buffer_ = nullptr; + double* heap_space_statistics_buffer_ = nullptr; char* http_parser_buffer_; diff --git a/src/node_v8.cc b/src/node_v8.cc index a1122e57f13cac..75781ec478e80d 100644 --- a/src/node_v8.cc +++ b/src/node_v8.cc @@ -56,8 +56,8 @@ void UpdateHeapStatisticsArrayBuffer(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); HeapStatistics s; env->isolate()->GetHeapStatistics(&s); - uint32_t* const buffer = env->heap_statistics_buffer(); -#define V(index, name, _) buffer[index] = static_cast(s.name()); + double* const buffer = env->heap_statistics_buffer(); +#define V(index, name, _) buffer[index] = static_cast(s.name()); HEAP_STATISTICS_PROPERTIES(V) #undef V } @@ -67,13 +67,13 @@ void UpdateHeapSpaceStatisticsBuffer(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); HeapSpaceStatistics s; Isolate* const isolate = env->isolate(); - uint32_t* buffer = env->heap_space_statistics_buffer(); + double* buffer = env->heap_space_statistics_buffer(); for (size_t i = 0; i < number_of_heap_spaces; i++) { isolate->GetHeapSpaceStatistics(&s, i); size_t const property_offset = i * kHeapSpaceStatisticsPropertiesCount; #define V(index, name, _) buffer[property_offset + index] = \ - static_cast(s.name()); + static_cast(s.name()); HEAP_SPACE_STATISTICS_PROPERTIES(V) #undef V } @@ -102,7 +102,7 @@ void InitializeV8Bindings(Local target, "updateHeapStatisticsArrayBuffer", UpdateHeapStatisticsArrayBuffer); - env->set_heap_statistics_buffer(new uint32_t[kHeapStatisticsPropertiesCount]); + env->set_heap_statistics_buffer(new double[kHeapStatisticsPropertiesCount]); const size_t heap_statistics_buffer_byte_length = sizeof(*env->heap_statistics_buffer()) * kHeapStatisticsPropertiesCount; @@ -148,7 +148,7 @@ void InitializeV8Bindings(Local target, UpdateHeapSpaceStatisticsBuffer); env->set_heap_space_statistics_buffer( - new uint32_t[kHeapSpaceStatisticsPropertiesCount * number_of_heap_spaces]); + new double[kHeapSpaceStatisticsPropertiesCount * number_of_heap_spaces]); const size_t heap_space_statistics_buffer_byte_length = sizeof(*env->heap_space_statistics_buffer()) * From d0dbf128842f07401178265c4d68ae4b8b872bb6 Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Mon, 2 Jan 2017 23:29:56 -0500 Subject: [PATCH 024/148] doc: update TheAlphaNerd to MylesBorins MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit new year new alias PR-URL: https://github.com/nodejs/node/pull/10586 Reviewed-By: Franziska Hinkelmann Reviewed-By: Jeremiah Senkpiel Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Gibson Fahnestock Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Michaël Zasso --- README.md | 4 ++-- doc/onboarding-extras.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 59aa20d8e8bce1..7f645e350f418b 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,8 @@ more information about the governance of the Node.js project, see **Julien Gilli** <jgilli@nodejs.org> * [mscdex](https://github.com/mscdex) - **Brian White** <mscdex@mscdex.net> +* [MylesBorins](https://github.com/MylesBorins) - +**Myles Borins** <myles.borins@gmail.com> * [ofrobots](https://github.com/ofrobots) - **Ali Ijaz Sheikh** <ofrobots@google.com> * [rvagg](https://github.com/rvagg) - @@ -186,8 +188,6 @@ more information about the governance of the Node.js project, see **Shigeki Ohtsu** <ohtsu@iij.ad.jp> * [targos](https://github.com/targos) - **Michaël Zasso** <targos@protonmail.com> -* [TheAlphaNerd](https://github.com/TheAlphaNerd) - -**Myles Borins** <myles.borins@gmail.com> * [thefourtheye](https://github.com/thefourtheye) - **Sakthipriyan Vairamani** <thechargingvolcano@gmail.com> * [trevnorris](https://github.com/trevnorris) - diff --git a/doc/onboarding-extras.md b/doc/onboarding-extras.md index e19e1ef5795525..7e9afa87bc6d62 100644 --- a/doc/onboarding-extras.md +++ b/doc/onboarding-extras.md @@ -24,7 +24,7 @@ | `tools/eslint`, `.eslintrc` | @silverwind, @trott | | async_hooks | @nodejs/diagnostics | | upgrading V8 | @nodejs/v8, @nodejs/post-mortem | -| upgrading npm | @fishrock123, @thealphanerd | +| upgrading npm | @fishrock123, @MylesBorins | | upgrading c-ares | @jbergstroem | | upgrading http-parser | @jbergstroem, @nodejs/http | | upgrading libuv | @saghul | From 994f562858dc6f034ff20b327358f98b7821640a Mon Sep 17 00:00:00 2001 From: Kai Cataldo Date: Mon, 2 Jan 2017 16:50:04 -0500 Subject: [PATCH 025/148] assert: update comments Remove the numbers from the comments to make it clear that assert does not follow the [CJS spec](http://wiki.commonjs.org/wiki/Unit_Testing/1.0). Additionally, clean up the existing comments for consistent formatting/language and ease of reading. PR-URL: https://github.com/nodejs/node/pull/10579 Fixes: https://github.com/nodejs/node/issues/9063 Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Benjamin Gruenbaum Reviewed-By: Michael Dawson --- lib/assert.js | 74 +++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 32 deletions(-) diff --git a/lib/assert.js b/lib/assert.js index 469128f39b4911..ac3782321af6b5 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -30,16 +30,16 @@ const util = require('util'); const Buffer = require('buffer').Buffer; const pToString = (obj) => Object.prototype.toString.call(obj); -// 1. The assert module provides functions that throw +// The assert module provides functions that throw // AssertionError's when particular conditions are not met. The // assert module must conform to the following interface. const assert = module.exports = ok; -// 2. The AssertionError is defined in assert. +// The AssertionError is defined in assert. // new assert.AssertionError({ message: message, // actual: actual, -// expected: expected }) +// expected: expected }); assert.AssertionError = function AssertionError(options) { this.name = 'AssertionError'; @@ -75,7 +75,7 @@ function getMessage(self) { // other keys to the AssertionError's constructor - they will be // ignored. -// 3. All of the following functions must throw an AssertionError +// All of the following functions must throw an AssertionError // when a corresponding condition is not met, with a message that // may be undefined if not provided. All assertion methods provide // both the actual and expected values to the assertion error for @@ -94,7 +94,7 @@ function fail(actual, expected, message, operator, stackStartFunction) { // EXTENSION! allows for well behaved errors defined elsewhere. assert.fail = fail; -// 4. Pure assertion tests whether a value is truthy, as determined +// Pure assertion tests whether a value is truthy, as determined // by !!guard. // assert.ok(guard, message_opt); // This statement is equivalent to assert.equal(true, !!guard, @@ -106,7 +106,7 @@ function ok(value, message) { } assert.ok = ok; -// 5. The equality assertion tests shallow, coercive equality with +// The equality assertion tests shallow, coercive equality with // ==. // assert.equal(actual, expected, message_opt); @@ -114,8 +114,9 @@ assert.equal = function equal(actual, expected, message) { if (actual != expected) fail(actual, expected, message, '==', assert.equal); }; -// 6. The non-equality assertion tests for whether two objects are not equal -// with != assert.notEqual(actual, expected, message_opt); +// The non-equality assertion tests for whether two objects are not +// equal with !=. +// assert.notEqual(actual, expected, message_opt); assert.notEqual = function notEqual(actual, expected, message) { if (actual == expected) { @@ -123,7 +124,7 @@ assert.notEqual = function notEqual(actual, expected, message) { } }; -// 7. The equivalence assertion tests a deep equality relation. +// The equivalence assertion tests a deep equality relation. // assert.deepEqual(actual, expected, message_opt); assert.deepEqual = function deepEqual(actual, expected, message) { @@ -139,18 +140,22 @@ assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { }; function _deepEqual(actual, expected, strict, memos) { - // 7.1. All identical values are equivalent, as determined by ===. + // All identical values are equivalent, as determined by ===. if (actual === expected) { return true; + + // If both values are instances of buffers, equivalence is + // determined by comparing the values and ensuring the result + // === 0. } else if (actual instanceof Buffer && expected instanceof Buffer) { return compare(actual, expected) === 0; - // 7.2. If the expected value is a Date object, the actual value is + // If the expected value is a Date object, the actual value is // equivalent if it is also a Date object that refers to the same time. } else if (util.isDate(actual) && util.isDate(expected)) { return actual.getTime() === expected.getTime(); - // 7.3 If the expected value is a RegExp object, the actual value is + // If the expected value is a RegExp object, the actual value is // equivalent if it is also a RegExp object with the same source and // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). } else if (util.isRegExp(actual) && util.isRegExp(expected)) { @@ -160,18 +165,18 @@ function _deepEqual(actual, expected, strict, memos) { actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase; - // 7.4. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. + // If both values are primitives, equivalence is determined by + // == or, if checking for strict equivalence, ===. } else if ((actual === null || typeof actual !== 'object') && (expected === null || typeof expected !== 'object')) { return strict ? actual === expected : actual == expected; // If both values are instances of typed arrays, wrap their underlying - // ArrayBuffers in a Buffer each to increase performance + // ArrayBuffers in a Buffer to increase performance. // This optimization requires the arrays to have the same type as checked by - // Object.prototype.toString (aka pToString). Never perform binary - // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their - // bit patterns are not identical. + // Object.prototype.toString (pToString). Never perform binary + // comparisons for Float*Arrays, though, since +0 === -0 is true despite the + // two values' bit patterns not being identical. } else if (ArrayBuffer.isView(actual) && ArrayBuffer.isView(expected) && pToString(actual) === pToString(expected) && !(actual instanceof Float32Array || @@ -184,7 +189,7 @@ function _deepEqual(actual, expected, strict, memos) { expected.byteOffset + expected.byteLength)) === 0; - // 7.5 For all other Object pairs, including Array objects, equivalence is + // For all other Object pairs, including Array objects, equivalence is // determined by having the same number of owned properties (as verified // with Object.prototype.hasOwnProperty.call), the same set of keys // (although not necessarily the same order), equivalent values for every @@ -214,7 +219,8 @@ function isArguments(object) { function objEquiv(a, b, strict, actualVisitedObjects) { if (a === null || a === undefined || b === null || b === undefined) return false; - // if one is a primitive, the other must be same + + // If one is a primitive, the other must be the same. if (util.isPrimitive(a) || util.isPrimitive(b)) return a === b; if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) @@ -226,20 +232,23 @@ function objEquiv(a, b, strict, actualVisitedObjects) { const ka = Object.keys(a); const kb = Object.keys(b); var key, i; - // having the same number of owned properties (keys incorporates - // hasOwnProperty) + + // The pair must have the same number of owned properties (keys + // incorporates hasOwnProperty). if (ka.length !== kb.length) return false; - //the same set of keys (although not necessarily the same order), + + // The pair must have the same set of keys (although not + // necessarily in the same order). ka.sort(); kb.sort(); - //~~~cheap key test + // Cheap key test: for (i = ka.length - 1; i >= 0; i--) { if (ka[i] !== kb[i]) return false; } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test + // The pair must have equivalent values for every corresponding key. + // Possibly expensive deep test: for (i = ka.length - 1; i >= 0; i--) { key = ka[i]; if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) @@ -248,7 +257,7 @@ function objEquiv(a, b, strict, actualVisitedObjects) { return true; } -// 8. The non-equivalence assertion tests for any deep inequality. +// The non-equivalence assertion tests for any deep inequality. // assert.notDeepEqual(actual, expected, message_opt); assert.notDeepEqual = function notDeepEqual(actual, expected, message) { @@ -265,7 +274,7 @@ function notDeepStrictEqual(actual, expected, message) { } -// 9. The strict equality assertion tests strict equality, as determined by ===. +// The strict equality assertion tests strict equality, as determined by ===. // assert.strictEqual(actual, expected, message_opt); assert.strictEqual = function strictEqual(actual, expected, message) { @@ -274,8 +283,9 @@ assert.strictEqual = function strictEqual(actual, expected, message) { } }; -// 10. The strict non-equality assertion tests for strict inequality, as -// determined by !==. assert.notStrictEqual(actual, expected, message_opt); +// The strict non-equality assertion tests for strict inequality, as +// determined by !==. +// assert.notStrictEqual(actual, expected, message_opt); assert.notStrictEqual = function notStrictEqual(actual, expected, message) { if (actual === expected) { @@ -297,7 +307,7 @@ function expectedException(actual, expected) { return true; } } catch (e) { - // Ignore. The instanceof check doesn't work for arrow functions. + // Ignore. The instanceof check doesn't work for arrow functions. } if (Error.isPrototypeOf(expected)) { @@ -355,7 +365,7 @@ function _throws(shouldThrow, block, expected, message) { } } -// 11. Expected to throw an error: +// Expected to throw an error. // assert.throws(block, Error_opt, message_opt); assert.throws = function(block, /*optional*/error, /*optional*/message) { From a597c11ba4c85dc9914466afb883e65552a50d9c Mon Sep 17 00:00:00 2001 From: Brian White Date: Sat, 24 Dec 2016 23:29:22 -0500 Subject: [PATCH 026/148] benchmark: improve readability of net benchmarks PR-URL: https://github.com/nodejs/node/pull/10446 Reviewed-By: James M Snell --- benchmark/net/net-c2s.js | 20 ++++++++++---------- benchmark/net/net-pipe.js | 20 ++++++++++---------- benchmark/net/net-s2c.js | 20 ++++++++++---------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/benchmark/net/net-c2s.js b/benchmark/net/net-c2s.js index 370ff4f138cafd..471389e2687423 100644 --- a/benchmark/net/net-c2s.js +++ b/benchmark/net/net-c2s.js @@ -65,8 +65,17 @@ Writer.prototype.once = function() {}; Writer.prototype.emit = function() {}; +function flow() { + var dest = this.dest; + var res = dest.write(chunk, encoding); + if (!res) + dest.once('drain', this.flow); + else + process.nextTick(this.flow); +} + function Reader() { - this.flow = this.flow.bind(this); + this.flow = flow.bind(this); this.readable = true; } @@ -76,15 +85,6 @@ Reader.prototype.pipe = function(dest) { return dest; }; -Reader.prototype.flow = function() { - var dest = this.dest; - var res = dest.write(chunk, encoding); - if (!res) - dest.once('drain', this.flow); - else - process.nextTick(this.flow); -}; - function server() { var reader = new Reader(); diff --git a/benchmark/net/net-pipe.js b/benchmark/net/net-pipe.js index ea8af249a35b50..feec0f268a7773 100644 --- a/benchmark/net/net-pipe.js +++ b/benchmark/net/net-pipe.js @@ -65,8 +65,17 @@ Writer.prototype.once = function() {}; Writer.prototype.emit = function() {}; +function flow() { + var dest = this.dest; + var res = dest.write(chunk, encoding); + if (!res) + dest.once('drain', this.flow); + else + process.nextTick(this.flow); +} + function Reader() { - this.flow = this.flow.bind(this); + this.flow = flow.bind(this); this.readable = true; } @@ -76,15 +85,6 @@ Reader.prototype.pipe = function(dest) { return dest; }; -Reader.prototype.flow = function() { - var dest = this.dest; - var res = dest.write(chunk, encoding); - if (!res) - dest.once('drain', this.flow); - else - process.nextTick(this.flow); -}; - function server() { var reader = new Reader(); diff --git a/benchmark/net/net-s2c.js b/benchmark/net/net-s2c.js index af40d8d58d8852..118f0267ae952a 100644 --- a/benchmark/net/net-s2c.js +++ b/benchmark/net/net-s2c.js @@ -65,8 +65,17 @@ Writer.prototype.once = function() {}; Writer.prototype.emit = function() {}; +function flow() { + var dest = this.dest; + var res = dest.write(chunk, encoding); + if (!res) + dest.once('drain', this.flow); + else + process.nextTick(this.flow); +} + function Reader() { - this.flow = this.flow.bind(this); + this.flow = flow.bind(this); this.readable = true; } @@ -76,15 +85,6 @@ Reader.prototype.pipe = function(dest) { return dest; }; -Reader.prototype.flow = function() { - var dest = this.dest; - var res = dest.write(chunk, encoding); - if (!res) - dest.once('drain', this.flow); - else - process.nextTick(this.flow); -}; - function server() { var reader = new Reader(); From 434b00be8a721971f3f1240554725f5c1fda1345 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Tue, 3 Jan 2017 22:14:59 -0800 Subject: [PATCH 027/148] meta: decharter the http working group Fixes: https://github.com/nodejs/CTC/issues/41 PR-URL: https://github.com/nodejs/node/pull/10604 Fixes: https://github.com/nodejs/CTC#41 Reviewed-By: Evan Lucas Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Michal Zasso Reviewed-By: Colin Ihrig --- WORKING_GROUPS.md | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/WORKING_GROUPS.md b/WORKING_GROUPS.md index 7b5dfe65a42e89..00eb770b0e2069 100644 --- a/WORKING_GROUPS.md +++ b/WORKING_GROUPS.md @@ -42,7 +42,6 @@ Top Level Working Group](https://github.com/nodejs/TSC/blob/master/WORKING_GROUP * [Benchmarking](#benchmarking) * [Post-mortem](#post-mortem) * [Intl](#intl) -* [HTTP](#http) * [Documentation](#documentation) * [Testing](#testing) @@ -189,21 +188,6 @@ Responsibilities include: * Publishing regular update summaries and other promotional content. -### [HTTP](https://github.com/nodejs/http) - -The HTTP Working Group is chartered for the support and improvement of the -HTTP implementation in Node.js. - -Responsibilities include: -* Addressing HTTP issues on the Node.js issue tracker. -* Authoring and editing HTTP documentation within the Node.js project. -* Reviewing changes to HTTP functionality within the Node.js project. -* Working with the ecosystem of HTTP related module developers to evolve the - HTTP implementation and APIs in core. -* Advising the CTC on all HTTP related issues and discussions. -* Messaging about the future of HTTP to give the community advance notice of - changes. - ### [Docker](https://github.com/nodejs/docker-iojs) The Docker Working Group's purpose is to build, maintain, and improve official From a7df34592151f4ecbb2e616ba117a16a788677f8 Mon Sep 17 00:00:00 2001 From: Arseniy Maximov Date: Thu, 23 Feb 2017 02:46:32 +0300 Subject: [PATCH 028/148] net: prefer === to == * Change === to == in one place * Add explanation about another non-strict if-statement PR-URL: https://github.com/nodejs/node/pull/11513 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- lib/net.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/net.js b/lib/net.js index 92dd52ebf78e61..c6005aeecfac69 100644 --- a/lib/net.js +++ b/lib/net.js @@ -137,6 +137,9 @@ function Socket(options) { } else if (options.fd !== undefined) { this._handle = createHandle(options.fd); this._handle.open(options.fd); + // options.fd can be string (since it user-defined), + // so changing this to === would be semver-major + // See: https://github.com/nodejs/node/pull/11513 if ((options.fd == 1 || options.fd == 2) && (this._handle instanceof Pipe) && process.platform === 'win32') { @@ -1057,7 +1060,7 @@ function afterConnect(status, handle, req, readable, writable) { self._connecting = false; self._sockname = null; - if (status == 0) { + if (status === 0) { self.readable = readable; self.writable = writable; self._unrefTimer(); From d622b673028a7de2eea2f0465ffbd4d796fa95ba Mon Sep 17 00:00:00 2001 From: Zach Bjornson Date: Fri, 24 Feb 2017 12:47:18 -0800 Subject: [PATCH 029/148] doc: document clientRequest.aborted Add documentation for http clientRequest.aborted. PR-URL: https://github.com/nodejs/node/pull/11544 Reviewed-By: Sam Roberts Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- doc/api/http.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/doc/api/http.md b/doc/api/http.md index 8b99ba5256735a..d47e0ae8c0f4be 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -410,6 +410,14 @@ added: v0.3.8 Marks the request as aborting. Calling this will cause remaining data in the response to be dropped and the socket to be destroyed. +### request.aborted + + +If a request has been aborted, this value is the time when the request was +aborted, in milliseconds since 1 January 1970 00:00:00 UTC. + ### request.end([data][, encoding][, callback]) +* `value` {any} +* `message` {any} An alias of [`assert.ok()`][] . @@ -36,6 +38,9 @@ assert(false, 'it\'s false'); +* `actual` {any} +* `expected` {any} +* `message` {any} Tests for deep equality between the `actual` and `expected` parameters. Primitive values are compared with the equal comparison operator ( `==` ). @@ -97,6 +102,9 @@ parameter is undefined, a default error message is assigned. +* `actual` {any} +* `expected` {any} +* `message` {any} Generally identical to `assert.deepEqual()` with two exceptions. First, primitive values are compared using the strict equality operator ( `===` ). @@ -121,6 +129,9 @@ parameter is undefined, a default error message is assigned. +* `block` {Function} +* `error` {RegExp|Function} +* `message` {any} Asserts that the function `block` does not throw an error. See [`assert.throws()`][] for more details. @@ -176,6 +187,9 @@ assert.doesNotThrow( +* `actual` {any} +* `expected` {any} +* `message` {any} Tests shallow, coercive equality between the `actual` and `expected` parameters using the equal comparison operator ( `==` ). @@ -202,6 +216,10 @@ parameter is undefined, a default error message is assigned. +* `actual` {any} +* `expected` {any} +* `message` {any} +* `operator` {String} Throws an `AssertionError`. If `message` is falsy, the error message is set as the values of `actual` and `expected` separated by the provided `operator`. @@ -221,6 +239,7 @@ assert.fail(1, 2, 'whoops', '>'); +* `value` {any} Throws `value` if `value` is truthy. This is useful when testing the `error` argument in callbacks. @@ -238,6 +257,9 @@ assert.ifError(new Error()); // Throws Error +* `actual` {any} +* `expected` {any} +* `message` {any} Tests for any deep inequality. Opposite of [`assert.deepEqual()`][]. @@ -282,6 +304,9 @@ parameter is undefined, a default error message is assigned. +* `actual` {any} +* `expected` {any} +* `message` {any} Tests for deep strict inequality. Opposite of [`assert.deepStrictEqual()`][]. @@ -303,6 +328,9 @@ the `message` parameter is undefined, a default error message is assigned. +* `actual` {any} +* `expected` {any} +* `message` {any} Tests shallow, coercive inequality with the not equal comparison operator ( `!=` ). @@ -328,6 +356,9 @@ parameter is undefined, a default error message is assigned. +* `actual` {any} +* `expected` {any} +* `message` {any} Tests strict inequality as determined by the strict not equal operator ( `!==` ). @@ -353,6 +384,8 @@ If the values are strictly equal, an `AssertionError` is thrown with a +* `value` {any} +* `message` {any} Tests if `value` is truthy. It is equivalent to `assert.equal(!!value, true, message)`. @@ -378,6 +411,9 @@ assert.ok(false, 'it\'s false'); +* `actual` {any} +* `expected` {any} +* `message` {any} Tests strict equality as determined by the strict equality operator ( `===` ). @@ -402,6 +438,9 @@ If the values are not strictly equal, an `AssertionError` is thrown with a +* `block` {Function} +* `error` {RegExp|Function} +* `message` {any} Expects the function `block` to throw an error. From 75af859af72e597c6b9ff1a3155c3d77e69c4101 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 22 Feb 2017 13:49:52 -0800 Subject: [PATCH 032/148] assert: apply minor refactoring * Remove comment referring to the CommonJS Unit Testing 1.0 spec. This module is no longer intended to comply with that spec. * Remove puzzling "THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!" comment. No doubt, it made sense at one time. * Favor `===` over `==` in two places. PR-URL: https://github.com/nodejs/node/pull/11511 Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Sam Roberts Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Joyee Cheung Reviewed-By: Luigi Pinca --- lib/assert.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/assert.js b/lib/assert.js index ac3782321af6b5..e5b4edb76ec655 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -1,7 +1,3 @@ -// http://wiki.commonjs.org/wiki/Unit_Testing/1.0 -// -// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8! -// // Originally from narwhal.js (http://narwhaljs.org) // Copyright (c) 2009 Thomas Robinson <280north.com> // @@ -213,7 +209,7 @@ function _deepEqual(actual, expected, strict, memos) { } function isArguments(object) { - return Object.prototype.toString.call(object) == '[object Arguments]'; + return Object.prototype.toString.call(object) === '[object Arguments]'; } function objEquiv(a, b, strict, actualVisitedObjects) { @@ -298,7 +294,7 @@ function expectedException(actual, expected) { return false; } - if (Object.prototype.toString.call(expected) == '[object RegExp]') { + if (Object.prototype.toString.call(expected) === '[object RegExp]') { return expected.test(actual); } From f0c7c7fad4902344d0cd998fc0f1d47ea8bfcb9f Mon Sep 17 00:00:00 2001 From: Kunal Pathak Date: Thu, 23 Feb 2017 18:18:48 -0800 Subject: [PATCH 033/148] test: fix flaky test-vm-timeout-rethrow The intention of test case is to make sure that `timeout` property is honored and the code in context terminates and throws correct exception. However in test case, the code inside context would complete before `timeout` for windows and would sometimes fail. Updated the code so it guarantee to not complete execution until timeout is triggered. Fixes: https://github.com/nodejs/node/issues/11261 PR-URL: https://github.com/nodejs/node/pull/11530 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Josh Gavant --- test/sequential/test-vm-timeout-rethrow.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/sequential/test-vm-timeout-rethrow.js b/test/sequential/test-vm-timeout-rethrow.js index f0f9c0b9c51063..7e148bd4d0b94f 100644 --- a/test/sequential/test-vm-timeout-rethrow.js +++ b/test/sequential/test-vm-timeout-rethrow.js @@ -5,15 +5,9 @@ var vm = require('vm'); var spawn = require('child_process').spawn; if (process.argv[2] === 'child') { - var code = 'var j = 0;\n' + - 'for (var i = 0; i < 1000000; i++) j += add(i, i + 1);\n' + - 'j;'; + const code = 'while(true);'; - var ctx = vm.createContext({ - add: function(x, y) { - return x + y; - } - }); + const ctx = vm.createContext(); vm.runInContext(code, ctx, { timeout: 1 }); } else { From f4bc12dd119d2a962db6013e7eaf103df7ebeb34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Rodr=C3=ADguez=20Baquero?= Date: Wed, 22 Feb 2017 01:41:07 -0500 Subject: [PATCH 034/148] doc: note message event listeners ref IPC channels The IPC channel is referenced with the message event too. PR-URL: https://github.com/nodejs/node/pull/11494 Reviewed-By: James M Snell Reviewed-By: Sam Roberts Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- doc/api/child_process.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 18ba0095620cc9..e60416ed2c22d0 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -536,9 +536,9 @@ spawn('prg', [], { stdio: ['pipe', null, null, null, 'pipe'] }); *It is worth noting that when an IPC channel is established between the parent and child processes, and the child is a Node.js process, the child is launched with the IPC channel unreferenced (using `unref()`) until the -child registers an event handler for the `process.on('disconnected')` event. -This allows the child to exit normally without the process being held open -by the open IPC channel.* +child registers an event handler for the `process.on('disconnect')` event +or the `process.on('message')` event.This allows the child to exit normally +without the process being held open by the open IPC channel.* See also: [`child_process.exec()`][] and [`child_process.fork()`][] From f0eee61a93732c2679288a5599d25df17719251e Mon Sep 17 00:00:00 2001 From: Jason Wilson Date: Tue, 21 Feb 2017 13:59:24 -0500 Subject: [PATCH 035/148] test: throw check in test-zlib-write-after-close PR-URL: https://github.com/nodejs/node/pull/11482 Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Yuta Hiroto --- test/parallel/test-zlib-write-after-close.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/test/parallel/test-zlib-write-after-close.js b/test/parallel/test-zlib-write-after-close.js index b346d2069a5e96..0cd590a4abbfce 100644 --- a/test/parallel/test-zlib-write-after-close.js +++ b/test/parallel/test-zlib-write-after-close.js @@ -6,7 +6,5 @@ var zlib = require('zlib'); zlib.gzip('hello', common.mustCall(function(err, out) { var unzip = zlib.createGunzip(); unzip.close(common.mustCall(function() {})); - assert.throws(function() { - unzip.write(out); - }); + assert.throws(() => unzip.write(out), /^Error: zlib binding closed$/); })); From bfc553d55d0b3aff6d45d1151cb0c181edb88ebb Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Thu, 9 Feb 2017 10:42:29 -0800 Subject: [PATCH 036/148] build: fail on CI if leftover processes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If any tests leave processes running after testing results are complete, fail the test run. PR-URL: https://github.com/nodejs/node/pull/11269 Reviewed-By: James M Snell Reviewed-By: Santiago Gimeno Reviewed-By: Michael Dawson Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Johan Bergström --- Makefile | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Makefile b/Makefile index f9293d6d6c0174..3d874d1ec332ff 100644 --- a/Makefile +++ b/Makefile @@ -199,12 +199,22 @@ test-ci-js: $(PYTHON) tools/test.py -p tap --logfile test.tap \ --mode=release --flaky-tests=$(FLAKY_TESTS) \ $(TEST_CI_ARGS) $(CI_JS_SUITES) + # Clean up any leftover processes + PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \ + if [ "$${PS_OUT}" ]; then \ + echo $${PS_OUT} | $(XARGS) kill; exit 1; \ + fi test-ci: LOGLEVEL := info test-ci: | build-addons out/Release/cctest --gtest_output=tap:cctest.tap $(PYTHON) tools/test.py -p tap --logfile test.tap --mode=release --flaky-tests=$(FLAKY_TESTS) \ $(TEST_CI_ARGS) $(CI_NATIVE_SUITES) $(CI_JS_SUITES) + # Clean up any leftover processes + PS_OUT=`ps awwx | grep Release/node | grep -v grep | awk '{print $$1}'`; \ + if [ "$${PS_OUT}" ]; then \ + echo $${PS_OUT} | $(XARGS) kill; exit 1; \ + fi test-release: test-build $(PYTHON) tools/test.py --mode=release From da2adb71331a3d5663bb196bc72ca18919010188 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 21 Feb 2017 12:59:36 +0100 Subject: [PATCH 037/148] src: update http-parser link I noticed that the link to http-parser is pointing to the joyent organization. There is a redirect to the nodejs organization but perhaps this should be updated anyway. PR-URL: https://github.com/nodejs/node/pull/11477 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- src/node_http_parser.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 23344b385b0dad..3e1a9d359e824e 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -16,7 +16,7 @@ #include // free() #include // strdup() -// This is a binding to http_parser (https://github.com/joyent/http-parser) +// This is a binding to http_parser (https://github.com/nodejs/http-parser) // The goal is to decouple sockets from parsing for more javascript-level // agility. A Buffer is read from a socket and passed to parser.execute(). // The parser then issues callbacks with slices of the data From 6a45ac0ea923f2523f423e1eb3dd1c9f829b4b09 Mon Sep 17 00:00:00 2001 From: Brian White Date: Mon, 20 Feb 2017 08:26:51 -0500 Subject: [PATCH 038/148] build: fix newlines in addon build output Interpretation of escape sequences with echo is not as consistent across platforms as printf, so use the latter instead. PR-URL: https://github.com/nodejs/node/pull/11466 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 3d874d1ec332ff..c7d3eabfe3acf8 100644 --- a/Makefile +++ b/Makefile @@ -156,7 +156,7 @@ test/addons/.buildstamp: config.gypi \ # Cannot use $(wildcard test/addons/*/) here, it's evaluated before # embedded addons have been generated from the documentation. @for dirname in test/addons/*/; do \ - echo "\nBuilding addon $$PWD/$$dirname" ; \ + printf "\nBuilding addon $$PWD/$$dirname\n" ; \ env MAKEFLAGS="-j1" $(NODE) deps/npm/node_modules/node-gyp/bin/node-gyp \ --loglevel=$(LOGLEVEL) rebuild \ --python="$(PYTHON)" \ From ef63af6006decaa82fc67b484a6404f2817b77cf Mon Sep 17 00:00:00 2001 From: Dmitry Tsvettsikh Date: Sat, 18 Feb 2017 17:12:22 +0500 Subject: [PATCH 039/148] tty: avoid oob warning in TTYWrap::GetWindowSize() PR-URL: https://github.com/nodejs/node/pull/11454 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- lib/tty.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tty.js b/lib/tty.js index 54a7b756ec9544..c00f2f5e796b34 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -66,7 +66,7 @@ function WriteStream(fd) { // Ref: https://github.com/nodejs/node/pull/1771#issuecomment-119351671 if (process.platform === 'darwin') this._handle.setBlocking(true); - var winSize = []; + var winSize = new Array(2); var err = this._handle.getWindowSize(winSize); if (!err) { this.columns = winSize[0]; @@ -83,7 +83,7 @@ WriteStream.prototype.isTTY = true; WriteStream.prototype._refreshSize = function() { var oldCols = this.columns; var oldRows = this.rows; - var winSize = []; + var winSize = new Array(2); var err = this._handle.getWindowSize(winSize); if (err) { this.emit('error', errnoException(err, 'getWindowSize')); From 53dd1a85392a722ceb32a962945158daad6177bc Mon Sep 17 00:00:00 2001 From: Fedor Indutny Date: Mon, 9 Jan 2017 08:38:31 -0500 Subject: [PATCH 040/148] tls: do not crash on STARTTLS when OCSP requested `TLSSocket` should not have a hard dependency on `tls.Server`, since it may be running without it in cases like `STARTTLS`. Fix: #10704 PR-URL: https://github.com/nodejs/node/pull/10706 Reviewed-By: James M Snell Reviewed-By: Sam Roberts Reviewed-By: Ben Noordhuis --- lib/_tls_wrap.js | 7 +++ test/parallel/test-tls-starttls-server.js | 53 +++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 test/parallel/test-tls-starttls-server.js diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 061f4d4182c9ac..cb435e45f26ef6 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -127,6 +127,13 @@ function requestOCSP(self, hello, ctx, cb) { if (!ctx) ctx = self.server._sharedCreds; + + // TLS socket is using a `net.Server` instead of a tls.TLSServer. + // Some TLS properties like `server._sharedCreds` will not be present + if (!ctx) + return cb(null); + + // TODO(indutny): eventually disallow raw `SecureContext` if (ctx.context) ctx = ctx.context; diff --git a/test/parallel/test-tls-starttls-server.js b/test/parallel/test-tls-starttls-server.js new file mode 100644 index 00000000000000..ca6a00b25ddc03 --- /dev/null +++ b/test/parallel/test-tls-starttls-server.js @@ -0,0 +1,53 @@ +'use strict'; + +// Test asynchronous SNI+OCSP on TLSSocket created with `server` set to +// `net.Server` instead of `tls.Server` + +const common = require('../common'); + +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + +const assert = require('assert'); +const fs = require('fs'); +const net = require('net'); +const tls = require('tls'); + +const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); +const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); + +const server = net.createServer(common.mustCall((s) => { + const tlsSocket = new tls.TLSSocket(s, { + isServer: true, + server: server, + + secureContext: tls.createSecureContext({ + key: key, + cert: cert + }), + + SNICallback: common.mustCall((hostname, callback) => { + assert.strictEqual(hostname, 'test.test'); + + callback(null, null); + }) + }); + + tlsSocket.on('secure', common.mustCall(() => { + tlsSocket.end(); + server.close(); + })); +})).listen(0, () => { + const opts = { + servername: 'test.test', + port: server.address().port, + rejectUnauthorized: false, + requestOCSP: true + }; + + tls.connect(opts, function() { + this.end(); + }); +}); From 9da6ebd73f6baba62aaea722088d962f411043c3 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sat, 11 Feb 2017 16:21:10 +0200 Subject: [PATCH 041/148] benchmark: add dgram bind(+/- params) benchmark Refs: https://github.com/nodejs/node/pull/11242 PR-URL: https://github.com/nodejs/node/pull/11313 Reviewed-By: Brian White --- benchmark/dgram/bind-params.js | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 benchmark/dgram/bind-params.js diff --git a/benchmark/dgram/bind-params.js b/benchmark/dgram/bind-params.js new file mode 100644 index 00000000000000..6f641f7f570667 --- /dev/null +++ b/benchmark/dgram/bind-params.js @@ -0,0 +1,38 @@ +'use strict'; + +const common = require('../common.js'); +const dgram = require('dgram'); + +const configs = { + n: [1e4], + port: ['true', 'false'], + address: ['true', 'false'], +}; + +const bench = common.createBenchmark(main, configs); + +function main(conf) { + const n = +conf.n; + const port = conf.port === 'true' ? 0 : undefined; + const address = conf.address === 'true' ? '0.0.0.0' : undefined; + + if (port !== undefined && address !== undefined) { + bench.start(); + for (let i = 0; i < n; i++) { + dgram.createSocket('udp4').bind(port, address).unref(); + } + bench.end(n); + } else if (port !== undefined) { + bench.start(); + for (let i = 0; i < n; i++) { + dgram.createSocket('udp4').bind(port).unref(); + } + bench.end(n); + } else if (port === undefined && address === undefined) { + bench.start(); + for (let i = 0; i < n; i++) { + dgram.createSocket('udp4').bind().unref(); + } + bench.end(n); + } +} From fa681ea55a4f53ee42cf2e3b31cf5ebed846aedc Mon Sep 17 00:00:00 2001 From: Tarang Hirani Date: Thu, 16 Feb 2017 12:44:13 +0530 Subject: [PATCH 042/148] test: add regex check to test-module-loading Also removes extraneous argument. PR-URL: https://github.com/nodejs/node/pull/11413 Reviewed-By: Colin Ihrig Reviewed-By: Gibson Fahnestock Reviewed-By: Yuta Hiroto --- test/sequential/test-module-loading.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js index 6125eefc360f00..0331c8318e362e 100644 --- a/test/sequential/test-module-loading.js +++ b/test/sequential/test-module-loading.js @@ -97,7 +97,8 @@ console.error('test name clashes'); var my_path = require('../fixtures/path'); assert.ok(my_path.path_func instanceof Function); // this one does not exist and should throw -assert.throws(function() { require('./utils'); }); +assert.throws(function() { require('./utils'); }, + /^Error: Cannot find module '.\/utils'$/); var errorThrown = false; try { @@ -124,7 +125,7 @@ assert.strictEqual(require('../fixtures/registerExt.hello.world').test, 'passed'); console.error('load custom file types that return non-strings'); -require.extensions['.test'] = function(module, filename) { +require.extensions['.test'] = function(module) { module.exports = { custom: 'passed' }; From 6abfcd560b30f049bcf13cda7248ff9b50ab587f Mon Sep 17 00:00:00 2001 From: QianJin2013 Date: Sun, 12 Feb 2017 18:45:42 +0900 Subject: [PATCH 043/148] doc: add comment for net.Server's error event Fixes: https://github.com/nodejs/node/issues/9710 PR-URL: https://github.com/nodejs/node/pull/11136 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Sam Roberts --- doc/api/net.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/api/net.md b/doc/api/net.md index c42f1a1e65ed70..db18b88c46d527 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -40,8 +40,10 @@ added: v0.1.90 * {Error} -Emitted when an error occurs. The [`'close'`][] event will be called directly -following this event. See example in discussion of `server.listen`. +Emitted when an error occurs. Unlike [`net.Socket`][], the [`'close'`][] +event will **not** be emitted directly following this event unless +[`server.close()`][] is manually called. See the example in discussion of +[`server.listen()`][`server.listen(port, host, backlog, callback)`]. ### Event: 'listening' diff --git a/doc/api/punycode.md b/doc/api/punycode.md index fee8a2436683d0..8343abda358336 100644 --- a/doc/api/punycode.md +++ b/doc/api/punycode.md @@ -1,4 +1,4 @@ -# punycode +# Punycode > Stability: 2 - Stable diff --git a/doc/api/string_decoder.md b/doc/api/string_decoder.md index 410ca5e0c98123..26f665a610890d 100644 --- a/doc/api/string_decoder.md +++ b/doc/api/string_decoder.md @@ -1,4 +1,4 @@ -# StringDecoder +# String Decoder > Stability: 2 - Stable diff --git a/doc/api/util.md b/doc/api/util.md index 662c360359a307..44437b61306f9b 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -1,4 +1,4 @@ -# util +# Util > Stability: 2 - Stable diff --git a/doc/api/vm.md b/doc/api/vm.md index a09c3bf20ca722..0b161e82c3c38d 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -1,4 +1,4 @@ -# Executing JavaScript +# VM (Executing JavaScript) > Stability: 2 - Stable From e1e02efac569824a5fb893751539f33cf622be18 Mon Sep 17 00:00:00 2001 From: Nikolai Vavilov Date: Thu, 9 Feb 2017 20:47:48 +0200 Subject: [PATCH 068/148] doc: clarify the behavior of Buffer.byteLength MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/11238 Refs: https://github.com/nodejs/node/issues/11165 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Michaël Zasso --- doc/api/buffer.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 7035fa254e77d9..e90d2f2616f8bd 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -528,6 +528,10 @@ Returns the actual byte length of a string. This is not the same as [`String.prototype.length`][] since that returns the number of *characters* in a string. +*Note* that for `'base64'` and `'hex'`, this function assumes valid input. For +strings that contain non-Base64/Hex-encoded data (e.g. whitespace), the return +value might be greater than the length of a `Buffer` created from the string. + Example: ```js From 6648b729b7a5c9bfd9b101211bf789086399eb18 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Fri, 5 Aug 2016 13:23:22 +0200 Subject: [PATCH 069/148] tools: add compile_commands.json gyp generator Add a compile_commands.json generator for use with clang-based tooling. Pass the (undocumented) -C switch to configure to make it generate the files in out/Debug and out/Release. PR-URL: https://github.com/nodejs/node/pull/7986 Reviewed-By: James M Snell --- configure | 9 ++ .../gyp/generator/compile_commands_json.py | 115 ++++++++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 tools/gyp/pylib/gyp/generator/compile_commands_json.py diff --git a/configure b/configure index 23c28f6bb84847..6eb106f92d520d 100755 --- a/configure +++ b/configure @@ -438,6 +438,12 @@ parser.add_option('--without-bundled-v8', help='do not use V8 includes from the bundled deps folder. ' + '(This mode is not officially supported for regular applications)') +# Create compile_commands.json in out/Debug and out/Release. +parser.add_option('-C', + action='store_true', + dest='compile_commands_json', + help=optparse.SUPPRESS_HELP) + (options, args) = parser.parse_args() # Expand ~ in the install prefix now, it gets written to multiple files. @@ -1286,6 +1292,9 @@ elif flavor == 'win' and sys.platform != 'msys': else: gyp_args += ['-f', 'make-' + flavor] +if options.compile_commands_json: + gyp_args += ['-f', 'compile_commands_json'] + gyp_args += args if warn.warned: diff --git a/tools/gyp/pylib/gyp/generator/compile_commands_json.py b/tools/gyp/pylib/gyp/generator/compile_commands_json.py new file mode 100644 index 00000000000000..575db63c4e1943 --- /dev/null +++ b/tools/gyp/pylib/gyp/generator/compile_commands_json.py @@ -0,0 +1,115 @@ +# Copyright (c) 2016 Ben Noordhuis . All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import gyp.common +import gyp.xcode_emulation +import json +import os + +generator_additional_non_configuration_keys = [] +generator_additional_path_sections = [] +generator_extra_sources_for_rules = [] +generator_filelist_paths = None +generator_supports_multiple_toolsets = True +generator_wants_sorted_dependencies = False + +# Lifted from make.py. The actual values don't matter much. +generator_default_variables = { + 'CONFIGURATION_NAME': '$(BUILDTYPE)', + 'EXECUTABLE_PREFIX': '', + 'EXECUTABLE_SUFFIX': '', + 'INTERMEDIATE_DIR': '$(obj).$(TOOLSET)/$(TARGET)/geni', + 'PRODUCT_DIR': '$(builddir)', + 'RULE_INPUT_DIRNAME': '%(INPUT_DIRNAME)s', + 'RULE_INPUT_EXT': '$(suffix $<)', + 'RULE_INPUT_NAME': '$(notdir $<)', + 'RULE_INPUT_PATH': '$(abspath $<)', + 'RULE_INPUT_ROOT': '%(INPUT_ROOT)s', + 'SHARED_INTERMEDIATE_DIR': '$(obj)/gen', + 'SHARED_LIB_PREFIX': 'lib', + 'STATIC_LIB_PREFIX': 'lib', + 'STATIC_LIB_SUFFIX': '.a', +} + + +def IsMac(params): + return 'mac' == gyp.common.GetFlavor(params) + + +def CalculateVariables(default_variables, params): + default_variables.setdefault('OS', gyp.common.GetFlavor(params)) + + +def AddCommandsForTarget(cwd, target, params, per_config_commands): + output_dir = params['generator_flags']['output_dir'] + for configuration_name, configuration in target['configurations'].iteritems(): + builddir_name = os.path.join(output_dir, configuration_name) + + if IsMac(params): + xcode_settings = gyp.xcode_emulation.XcodeSettings(target) + cflags = xcode_settings.GetCflags(configuration_name) + cflags_c = xcode_settings.GetCflagsC(configuration_name) + cflags_cc = xcode_settings.GetCflagsCC(configuration_name) + else: + cflags = configuration.get('cflags', []) + cflags_c = configuration.get('cflags_c', []) + cflags_cc = configuration.get('cflags_cc', []) + + cflags_c = cflags + cflags_c + cflags_cc = cflags + cflags_cc + + defines = configuration.get('defines', []) + defines = ['-D' + s for s in defines] + + # TODO(bnoordhuis) Handle generated source files. + sources = target.get('sources', []) + sources = [s for s in sources if s.endswith('.c') or s.endswith('.cc')] + + def resolve(filename): + return os.path.abspath(os.path.join(cwd, filename)) + + # TODO(bnoordhuis) Handle generated header files. + include_dirs = configuration.get('include_dirs', []) + include_dirs = [s for s in include_dirs if not s.startswith('$(obj)')] + includes = ['-I' + resolve(s) for s in include_dirs] + + defines = gyp.common.EncodePOSIXShellList(defines) + includes = gyp.common.EncodePOSIXShellList(includes) + cflags_c = gyp.common.EncodePOSIXShellList(cflags_c) + cflags_cc = gyp.common.EncodePOSIXShellList(cflags_cc) + + commands = per_config_commands.setdefault(configuration_name, []) + for source in sources: + file = resolve(source) + isc = source.endswith('.c') + cc = 'cc' if isc else 'c++' + cflags = cflags_c if isc else cflags_cc + command = ' '.join((cc, defines, includes, cflags, + '-c', gyp.common.EncodePOSIXShellArgument(file))) + commands.append(dict(command=command, directory=output_dir, file=file)) + + +def GenerateOutput(target_list, target_dicts, data, params): + per_config_commands = {} + for qualified_target, target in target_dicts.iteritems(): + build_file, target_name, toolset = ( + gyp.common.ParseQualifiedTarget(qualified_target)) + if IsMac(params): + settings = data[build_file] + gyp.xcode_emulation.MergeGlobalXcodeSettingsToSpec(settings, target) + cwd = os.path.dirname(build_file) + AddCommandsForTarget(cwd, target, params, per_config_commands) + + output_dir = params['generator_flags']['output_dir'] + for configuration_name, commands in per_config_commands.iteritems(): + filename = os.path.join(output_dir, + configuration_name, + 'compile_commands.json') + gyp.common.EnsureDirExists(filename) + fp = open(filename, 'w') + json.dump(commands, fp=fp, indent=0, check_circular=False) + + +def PerformBuild(data, configurations, params): + pass From bb1e97c31ac6762235606a03f8d6d02a2129c10e Mon Sep 17 00:00:00 2001 From: Daiki Arai Date: Wed, 25 Jan 2017 00:49:53 +0900 Subject: [PATCH 070/148] doc: add and fix System Error properties About path, address and port properties, these are not described though being also represented as augmented Error objects with added properties. And also, fix all property descriptions and add type annotations. PR-URL: https://github.com/nodejs/node/pull/10986 Reviewed-By: James M Snell Reviewed-By: Sam Roberts --- doc/api/errors.md | 62 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 10 deletions(-) diff --git a/doc/api/errors.md b/doc/api/errors.md index 5f451880f14332..c12100c19905cb 100644 --- a/doc/api/errors.md +++ b/doc/api/errors.md @@ -195,6 +195,8 @@ will either be instances of, or inherit from, the `Error` class. ### new Error(message) +* `message` {String} + Creates a new `Error` object and sets the `error.message` property to the provided text message. If an object is passed as `message`, the text message is generated by calling `message.toString()`. The `error.stack` property will @@ -205,6 +207,9 @@ given by the property `Error.stackTraceLimit`, whichever is smaller. ### Error.captureStackTrace(targetObject[, constructorOpt]) +* `targetObject` {Object} +* `constructorOpt` {Function} + Creates a `.stack` property on `targetObject`, which when accessed returns a string representing the location in the code at which `Error.captureStackTrace()` was called. @@ -238,6 +243,8 @@ new MyError().stack ### Error.stackTraceLimit +* {Number} + The `Error.stackTraceLimit` property specifies the number of stack frames collected by a stack trace (whether generated by `new Error().stack` or `Error.captureStackTrace(obj)`). @@ -250,10 +257,13 @@ not capture any frames. #### error.message -Returns the string description of error as set by calling `new Error(message)`. +* {String} + +The `error.message` property is the string description of the error as set by calling `new Error(message)`. The `message` passed to the constructor will also appear in the first line of the stack trace of the `Error`, however changing this property after the -`Error` object is created *may not* change the first line of the stack trace. +`Error` object is created *may not* change the first line of the stack trace +(for example, when `error.stack` is read before this property is changed). ```js const err = new Error('The message'); @@ -263,8 +273,10 @@ console.log(err.message); #### error.stack -Returns a string describing the point in the code at which the `Error` was -instantiated. +* {String} + +The `error.stack` property is a string describing the point in the code at which +the `Error` was instantiated. For example: @@ -450,18 +462,47 @@ added properties. #### error.code -Returns a string representing the error code, which is always `E` followed by -a sequence of capital letters, and may be referenced in `man 2 intro`. +* {String} + +The `error.code` property is a string representing the error code, which is always +`E` followed by a sequence of capital letters. #### error.errno -Returns a number corresponding to the **negated** error code, which may be -referenced in `man 2 intro`. For example, an `ENOENT` error has an `errno` of -`-2` because the error code for `ENOENT` is `2`. +* {String | Number} + +The `error.errno` property is a number or a string. +The number is a **negative** value which corresponds to the error code defined in +[`libuv Error handling`]. See uv-errno.h header file (`deps/uv/include/uv-errno.h` in +the Node.js source tree) for details. +In case of a string, it is the same as `error.code`. #### error.syscall -Returns a string describing the [syscall][] that failed. +* {String} + +The `error.syscall` property is a string describing the [syscall][] that failed. + +#### error.path + +* {String} + +When present (e.g. in `fs` or `child_process`), the `error.path` property is a string +containing a relevant invalid pathname. + +#### error.address + +* {String} + +When present (e.g. in `net` or `dgram`), the `error.address` property is a string +describing the address to which the connection failed. + +#### error.port + +* {Number} + +When present (e.g. in `net` or `dgram`), the `error.port` property is a number representing +the connection's port that is not available. ### Common System Errors @@ -528,6 +569,7 @@ found [here][online]. [`fs`]: fs.html [`http`]: http.html [`https`]: https.html +[`libuv Error handling`]: http://docs.libuv.org/en/v1.x/errors.html [`net`]: net.html [`process.on('uncaughtException')`]: process.html#process_event_uncaughtexception [domains]: domain.html From ca4b2f6154be91224c46321521d1959ccf2bd45e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 5 Feb 2017 13:25:01 -0800 Subject: [PATCH 071/148] doc: fix typo in dgram doc There is a typographical error in the dgram documentation. Reword to eliminate the error and increase clarity. PR-URL: https://github.com/nodejs/node/pull/11186 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Luigi Pinca --- doc/api/dgram.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/api/dgram.md b/doc/api/dgram.md index b80289f6c99bdd..5ec7db69cd4f29 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -413,8 +413,8 @@ boolean `reuseAddr` field. When `reuseAddr` is `true` [`socket.bind()`][] will reuse the address, even if another process has already bound a socket on it. `reuseAddr` defaults to -`false`. An optional `callback` function can be passed specified which is added -as a listener for `'message'` events. +`false`. The optional `callback` function is added as a listener for `'message'` +events. Once the socket is created, calling [`socket.bind()`][] will instruct the socket to begin listening for datagram messages. When `address` and `port` are From 4bb61553f00740efdfa1f133cceb84f7aad286c4 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Mon, 6 Feb 2017 22:48:26 +0100 Subject: [PATCH 072/148] build: disable C4267 conversion compiler warning Disable "warning C4267: conversion from 'size_t' to 'int', possible loss of data". Many originate from our dependencies and their sheer number drowns out other, more legitimate warnings. PR-URL: https://github.com/nodejs/node/pull/11205 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- common.gypi | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common.gypi b/common.gypi index 4aa8f919fb6d2f..d7b09570aded6d 100644 --- a/common.gypi +++ b/common.gypi @@ -186,6 +186,10 @@ 'BufferSecurityCheck': 'true', 'ExceptionHandling': 0, # /EHsc 'SuppressStartupBanner': 'true', + # Disable "warning C4267: conversion from 'size_t' to 'int', + # possible loss of data". Many originate from our dependencies + # and their sheer number drowns out other, more legitimate warnings. + 'DisableSpecificWarnings': ['4267'], 'WarnAsError': 'false', }, 'VCLibrarianTool': { From c532c16e53e071074553700abbc9a3d45bf356b0 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 5 Feb 2017 14:02:30 -0800 Subject: [PATCH 073/148] test: increase specificity in dgram test Expand error message checking to include the entire error string in test-dgram-membership. PR-URL: https://github.com/nodejs/node/pull/11187 Reviewed-By: Yuta Hiroto Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Luigi Pinca --- test/parallel/test-dgram-membership.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-dgram-membership.js b/test/parallel/test-dgram-membership.js index 87807f13fa5f23..1543b9043f7738 100644 --- a/test/parallel/test-dgram-membership.js +++ b/test/parallel/test-dgram-membership.js @@ -12,7 +12,7 @@ const setup = dgram.createSocket.bind(dgram, {type: 'udp4', reuseAddr: true}); const socket = setup(); socket.close(common.mustCall(() => { assert.throws(() => { socket.addMembership(multicastAddress); }, - /Not running/); + /^Error: Not running$/); })); } @@ -21,7 +21,7 @@ const setup = dgram.createSocket.bind(dgram, {type: 'udp4', reuseAddr: true}); const socket = setup(); socket.close(common.mustCall(() => { assert.throws(() => { socket.dropMembership(multicastAddress); }, - /Not running/); + /^Error: Not running$/); })); } @@ -29,7 +29,7 @@ const setup = dgram.createSocket.bind(dgram, {type: 'udp4', reuseAddr: true}); { const socket = setup(); assert.throws(() => { socket.addMembership(); }, - /multicast address must be specified/); + /^Error: multicast address must be specified$/); socket.close(); } @@ -37,7 +37,7 @@ const setup = dgram.createSocket.bind(dgram, {type: 'udp4', reuseAddr: true}); { const socket = setup(); assert.throws(() => { socket.dropMembership(); }, - /multicast address must be specified/); + /^Error: multicast address must be specified$/); socket.close(); } @@ -69,7 +69,7 @@ const setup = dgram.createSocket.bind(dgram, {type: 'udp4', reuseAddr: true}); const socket = setup(); assert.throws( () => { socket.dropMembership(multicastAddress); }, - /EADDRNOTAVAIL/ + /^Error: dropMembership EADDRNOTAVAIL$/ ); socket.close(); } From aae768c599fceeedf6314a5ccb4c29bb0edf7960 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 4 Feb 2017 20:50:39 -0800 Subject: [PATCH 074/148] doc: remove extraneous paragraph from assert doc The stability index is explained elsewhere in the documentation. It is not necessary to repeat the information about Locked stability index in the assert documentation. PR-URL: https://github.com/nodejs/node/pull/11174 Reviewed-By: Luigi Pinca Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Joyee Cheung Reviewed-By: Michael Dawson --- doc/api/assert.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/api/assert.md b/doc/api/assert.md index fd62777245c125..31f8aa70702a1f 100644 --- a/doc/api/assert.md +++ b/doc/api/assert.md @@ -8,10 +8,6 @@ used in application code via `require('assert')`. However, `assert` is not a testing framework, and is not intended to be used as a general purpose assertion library. -The API for the `assert` module is [Locked][]. This means that there will be no -additions or changes to any of the methods implemented and exposed by -the module. - ## assert(value[, message]) * `options` {Object} - Required. Supports the following properties: - * `port` {Number} - Required. + * `port` {Number} - Optional. * `address` {String} - Optional. * `exclusive` {Boolean} - Optional. * `callback` {Function} - Optional. -For UDP sockets, causes the `dgram.Socket` to listen for datagram messages on a -named `port` and optional `address` that are passed as properties of an -`options` object passed as the first argument. If `port` is not specified, the -operating system will attempt to bind to a random port. If `address` is not -specified, the operating system will attempt to listen on all addresses. Once -binding is complete, a `'listening'` event is emitted and the optional -`callback` function is called. +For UDP sockets, causes the `dgram.Socket` to listen for datagram +messages on a named `port` and optional `address` that are passed as +properties of an `options` object passed as the first argument. If +`port` is not specified or is `0`, the operating system will attempt +to bind to a random port. If `address` is not specified, the operating +system will attempt to listen on all addresses. Once binding is +complete, a `'listening'` event is emitted and the optional `callback` +function is called. + +Note that specifying both a `'listening'` event listener and passing a +`callback` to the `socket.bind()` method is not harmful but not very +useful. The `options` object may contain an additional `exclusive` property that is use when using `dgram.Socket` objects with the [`cluster`] module. When @@ -179,6 +185,12 @@ underlying socket handle allowing connection handling duties to be shared. When `exclusive` is `true`, however, the handle is not shared and attempted port sharing results in an error. +A bound datagram socket keeps the Node.js process running to receive +datagram messages. + +If binding fails, an `'error'` event is generated. In rare case (e.g. +attempting to bind with a closed socket), an [`Error`][] may be thrown. + An example socket listening on an exclusive port is shown below. ```js From 15188900b8faa5ce3fa1580792ec026bb65f6201 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Fri, 27 Jan 2017 12:36:17 -0500 Subject: [PATCH 093/148] doc: add who to CC list for dgram PR-URL: https://github.com/nodejs/node/pull/11035 Reviewed-By: Gibson Fahnestock Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Evan Lucas --- doc/onboarding-extras.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/onboarding-extras.md b/doc/onboarding-extras.md index 3356c185decf47..556de7d54007fb 100644 --- a/doc/onboarding-extras.md +++ b/doc/onboarding-extras.md @@ -9,6 +9,7 @@ | `lib/child_process` | @bnoordhuis, @cjihrig | | `lib/cluster` | @bnoordhuis, @cjihrig, @mcollina | | `lib/{crypto,tls,https}` | @nodejs/crypto | +| `lib/dgram` | @cjihrig, @mcollina | | `lib/domains` | @misterdjules | | `lib/fs`, `src/{fs|file}` | @nodejs/fs | | `lib/{_}http{*}` | @nodejs/http | From db03294c41344acd2807e3b50af9375aeda60dc9 Mon Sep 17 00:00:00 2001 From: Peter Mescalchin Date: Tue, 24 Jan 2017 21:11:17 +1100 Subject: [PATCH 094/148] doc: fix typo in http.md A small document update, all other instances of HTTP header on this page are written as 'Content-Length'. This also matches casing used with RFC 2616. PR-URL: https://github.com/nodejs/node/pull/10975 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- doc/api/http.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/http.md b/doc/api/http.md index 8971fd32882190..7977e9f1c28a60 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -1429,7 +1429,7 @@ There are a few special headers that should be noted. * Sending a 'Connection: keep-alive' will notify Node.js that the connection to the server should be persisted until the next request. -* Sending a 'Content-length' header will disable the default chunked encoding. +* Sending a 'Content-Length' header will disable the default chunked encoding. * Sending an 'Expect' header will immediately send the request headers. Usually, when sending 'Expect: 100-continue', you should both set a timeout From c1f45ec2d055cac4f77298bd5fd41c2e831c1ee5 Mon Sep 17 00:00:00 2001 From: Marlena Compton Date: Sat, 28 Jan 2017 16:08:15 -0800 Subject: [PATCH 095/148] test: add 2nd argument to throws in test-assert PR-URL: https://github.com/nodejs/node/pull/11061 Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- test/parallel/test-assert.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 603da5c5f990e9..563f67e91e07a8 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -99,9 +99,11 @@ assert.throws(makeBlock(a.deepEqual, /a/m, /a/)); assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im)); { - const re1 = /a/; + const re1 = /a/g; re1.lastIndex = 3; - assert.throws(makeBlock(a.deepEqual, re1, /a/)); + + assert.throws(makeBlock(a.deepEqual, re1, /a/g), + /^AssertionError: \/a\/g deepEqual \/a\/g$/); } From 50a868b3f7f35b3b12247559bd0f20e56d4b7e0f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 29 Jan 2017 18:18:20 -0800 Subject: [PATCH 096/148] test: require handler to be run in sigwinch test Use `common.mustCall()` to guarantee that the wrapped `_refreshSize()` functions are invoked. PR-URL: https://github.com/nodejs/node/pull/11068 Reviewed-By: Colin Ihrig Reviewed-By: Jeremiah Senkpiel Reviewed-By: Santiago Gimeno Reviewed-By: James M Snell Reviewed-By: Michal Zasso --- test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js index f1a95559b9dc92..f828e92afbe71c 100644 --- a/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js +++ b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js @@ -5,7 +5,7 @@ const originalRefreshSizeStderr = process.stderr._refreshSize; const originalRefreshSizeStdout = process.stdout._refreshSize; const wrap = (fn, ioStream, string) => { - return () => { + const wrapped = common.mustCall(() => { // The console.log() call prints a string that is in the .out file. In other // words, the console.log() is part of the test, not extraneous debugging. console.log(string); @@ -16,7 +16,8 @@ const wrap = (fn, ioStream, string) => { if (!common.isSunOS || e.code !== 'EINVAL') throw e; } - }; + }); + return wrapped; }; process.stderr._refreshSize = wrap(originalRefreshSizeStderr, From 3f3c78d7851a37ddabe0f9fbd960ab22c0488ad8 Mon Sep 17 00:00:00 2001 From: Junshu Okamoto Date: Wed, 26 Oct 2016 02:30:12 -0700 Subject: [PATCH 097/148] test: refactor test-fs-utimes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * favor `===` over `==` * `var` -> `const`/`let` * use `common.mustCall()` PR-URL: https://github.com/nodejs/node/pull/9290 Reviewed-By: Michaël Zasso Reviewed-By: James M Snell --- test/parallel/test-fs-utimes.js | 43 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js index f245a7962da0f4..108ca7c7d71c03 100644 --- a/test/parallel/test-fs-utimes.js +++ b/test/parallel/test-fs-utimes.js @@ -4,11 +4,11 @@ var assert = require('assert'); var util = require('util'); var fs = require('fs'); -var tests_ok = 0; -var tests_run = 0; +let tests_ok = 0; +let tests_run = 0; function stat_resource(resource) { - if (typeof resource == 'string') { + if (typeof resource === 'string') { return fs.statSync(resource); } else { // ensure mtime has been written to disk @@ -19,8 +19,8 @@ function stat_resource(resource) { function check_mtime(resource, mtime) { mtime = fs._toUnixTimestamp(mtime); - var stats = stat_resource(resource); - var real_mtime = fs._toUnixTimestamp(stats.mtime); + const stats = stat_resource(resource); + const real_mtime = fs._toUnixTimestamp(stats.mtime); // check up to single-second precision // sub-second precision is OS and fs dependant return mtime - real_mtime < 2; @@ -46,9 +46,9 @@ function expect_ok(syscall, resource, err, atime, mtime) { // the tests assume that __filename belongs to the user running the tests // this should be a fairly safe assumption; testing against a temp file // would be even better though (node doesn't have such functionality yet) -function runTest(atime, mtime, callback) { +function testIt(atime, mtime, callback) { - var fd; + let fd; // // test synchronized code paths, these functions throw on failure // @@ -67,8 +67,7 @@ function runTest(atime, mtime, callback) { expect_errno('futimesSync', fd, ex, 'ENOSYS'); } - var err; - err = undefined; + let err = undefined; try { fs.utimesSync('foobarbaz', atime, mtime); } catch (ex) { @@ -90,10 +89,10 @@ function runTest(atime, mtime, callback) { // // test async code paths // - fs.utimes(__filename, atime, mtime, function(err) { + fs.utimes(__filename, atime, mtime, common.mustCall(function(err) { expect_ok('utimes', __filename, err, atime, mtime); - fs.utimes('foobarbaz', atime, mtime, function(err) { + fs.utimes('foobarbaz', atime, mtime, common.mustCall(function(err) { expect_errno('utimes', 'foobarbaz', err, 'ENOENT'); // don't close this fd @@ -103,34 +102,36 @@ function runTest(atime, mtime, callback) { fd = fs.openSync(__filename, 'r'); } - fs.futimes(fd, atime, mtime, function(err) { + fs.futimes(fd, atime, mtime, common.mustCall(function(err) { expect_ok('futimes', fd, err, atime, mtime); - fs.futimes(-1, atime, mtime, function(err) { + fs.futimes(-1, atime, mtime, common.mustCall(function(err) { expect_errno('futimes', -1, err, 'EBADF'); syncTests(); callback(); - }); + })); tests_run++; - }); + })); tests_run++; - }); + })); tests_run++; - }); + })); tests_run++; } -var stats = fs.statSync(__filename); +const stats = fs.statSync(__filename); // run tests +const runTest = common.mustCall(testIt, 6); + runTest(new Date('1982-09-10 13:37'), new Date('1982-09-10 13:37'), function() { runTest(new Date(), new Date(), function() { runTest(123456.789, 123456.789, function() { runTest(stats.mtime, stats.mtime, function() { runTest(NaN, Infinity, function() { - runTest('123456', -1, function() { + runTest('123456', -1, common.mustCall(function() { // done - }); + })); }); }); }); @@ -140,5 +141,5 @@ runTest(new Date('1982-09-10 13:37'), new Date('1982-09-10 13:37'), function() { process.on('exit', function() { console.log('Tests run / ok:', tests_run, '/', tests_ok); - assert.equal(tests_ok, tests_run); + assert.strictEqual(tests_ok, tests_run); }); From 1ae95e64eecd121743897796e5692e24936768ac Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Sun, 1 Jan 2017 23:48:58 -0500 Subject: [PATCH 098/148] test: improve test-fs-readfile-zero-byte-liar * use const instead of var * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10570 Reviewed-By: Luigi Pinca Reviewed-By: Italo A. Casas Reviewed-By: James M Snell --- .../test-fs-readfile-zero-byte-liar.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/parallel/test-fs-readfile-zero-byte-liar.js b/test/parallel/test-fs-readfile-zero-byte-liar.js index 283a986f8a038a..c3887979bb0b4a 100644 --- a/test/parallel/test-fs-readfile-zero-byte-liar.js +++ b/test/parallel/test-fs-readfile-zero-byte-liar.js @@ -3,29 +3,29 @@ const common = require('../common'); var assert = require('assert'); var fs = require('fs'); -var dataExpected = fs.readFileSync(__filename, 'utf8'); +const dataExpected = fs.readFileSync(__filename, 'utf8'); // sometimes stat returns size=0, but it's a lie. fs._fstat = fs.fstat; fs._fstatSync = fs.fstatSync; -fs.fstat = function(fd, cb) { - fs._fstat(fd, function(er, st) { +fs.fstat = (fd, cb) => { + fs._fstat(fd, (er, st) => { if (er) return cb(er); st.size = 0; return cb(er, st); }); }; -fs.fstatSync = function(fd) { - var st = fs._fstatSync(fd); +fs.fstatSync = (fd) => { + const st = fs._fstatSync(fd); st.size = 0; return st; }; -var d = fs.readFileSync(__filename, 'utf8'); -assert.equal(d, dataExpected); +const d = fs.readFileSync(__filename, 'utf8'); +assert.strictEqual(d, dataExpected); -fs.readFile(__filename, 'utf8', common.mustCall(function(er, d) { - assert.equal(d, dataExpected); +fs.readFile(__filename, 'utf8', common.mustCall((er, d) => { + assert.strictEqual(d, dataExpected); })); From 42b86ea968023434588693fa329d4e7cebdf7b3d Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Sat, 7 Jan 2017 10:56:53 -0500 Subject: [PATCH 099/148] test: improve test-http-chunked-304 * change the nested functions call to run tests in parallel * use const and let instead of var * use common.mustCall to control functions execution * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10462 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Italo A. Casas Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Prince John Wesley Reviewed-By: Luigi Pinca --- test/parallel/test-http-chunked-304.js | 45 ++++++++++++++------------ 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/test/parallel/test-http-chunked-304.js b/test/parallel/test-http-chunked-304.js index 5ea1912b72dfee..82fe138fd926da 100644 --- a/test/parallel/test-http-chunked-304.js +++ b/test/parallel/test-http-chunked-304.js @@ -12,32 +12,35 @@ var net = require('net'); // Likewise for 304 responses. Verify that no empty chunk is sent when // the user explicitly sets a Transfer-Encoding header. -test(204, function() { - test(304); -}); +test(204); +test(304); -function test(statusCode, next) { - var server = http.createServer(function(req, res) { +function test(statusCode) { + const server = http.createServer(common.mustCall((req, res) => { res.writeHead(statusCode, { 'Transfer-Encoding': 'chunked' }); res.end(); server.close(); - }); + })); - server.listen(0, function() { - var conn = net.createConnection(this.address().port, function() { - conn.write('GET / HTTP/1.1\r\n\r\n'); + server.listen(0, common.mustCall(() => { + const conn = net.createConnection( + server.address().port, + common.mustCall(() => { + conn.write('GET / HTTP/1.1\r\n\r\n'); - var resp = ''; - conn.setEncoding('utf8'); - conn.on('data', function(data) { - resp += data; - }); + let resp = ''; + conn.setEncoding('utf8'); + conn.on('data', common.mustCall((data) => { + resp += data; + })); - conn.on('end', common.mustCall(function() { - assert.equal(/^Connection: close\r\n$/m.test(resp), true); - assert.equal(/^0\r\n$/m.test(resp), false); - if (next) process.nextTick(next); - })); - }); - }); + conn.on('end', common.mustCall(() => { + // Connection: close should be in the response + assert.strictEqual(/^Connection: close\r\n$/m.test(resp), true); + // Make sure this doesn't end with 0\r\n\r\n + assert.strictEqual(/^0\r\n$/m.test(resp), false); + })); + }) + ); + })); } From 4453c0c1dcdf5abf98d91e8fb853bae145279cf9 Mon Sep 17 00:00:00 2001 From: sivaprasanna Date: Wed, 4 Jan 2017 13:03:20 +0530 Subject: [PATCH 100/148] test: refactor the code in test-child-process-spawn-loop.js * use const and let instead of var * use assert.strictEqual instead of assert.equal * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10605 Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell --- test/pummel/test-child-process-spawn-loop.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/pummel/test-child-process-spawn-loop.js b/test/pummel/test-child-process-spawn-loop.js index 7e686cada244b3..7a3cf114b4e8e9 100644 --- a/test/pummel/test-child-process-spawn-loop.js +++ b/test/pummel/test-child-process-spawn-loop.js @@ -4,26 +4,26 @@ var assert = require('assert'); var spawn = require('child_process').spawn; -var SIZE = 1000 * 1024; -var N = 40; -var finished = false; +const SIZE = 1000 * 1024; +const N = 40; +let finished = false; function doSpawn(i) { - var child = spawn('python', ['-c', 'print ' + SIZE + ' * "C"']); - var count = 0; + const child = spawn('python', ['-c', 'print ' + SIZE + ' * "C"']); + let count = 0; child.stdout.setEncoding('ascii'); - child.stdout.on('data', function(chunk) { + child.stdout.on('data', (chunk) => { count += chunk.length; }); - child.stderr.on('data', function(chunk) { + child.stderr.on('data', (chunk) => { console.log('stderr: ' + chunk); }); - child.on('close', function() { + child.on('close', () => { // + 1 for \n or + 2 for \r\n on Windows - assert.equal(SIZE + (common.isWindows ? 2 : 1), count); + assert.strictEqual(SIZE + (common.isWindows ? 2 : 1), count); if (i < N) { doSpawn(i + 1); } else { @@ -34,6 +34,6 @@ function doSpawn(i) { doSpawn(0); -process.on('exit', function() { +process.on('exit', () => { assert.ok(finished); }); From ab65429e44fc66992cd431400d44abc1ddd86d24 Mon Sep 17 00:00:00 2001 From: sivaprasanna Date: Sat, 7 Jan 2017 23:10:16 +0530 Subject: [PATCH 101/148] test: refactor test-watch-file.js * use const and let instead of var * use arrow function * removed console.log statements PR-URL: https://github.com/nodejs/node/pull/10679 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Italo A. Casas Reviewed-By: Sakthipriyan Vairamani --- test/pummel/test-watch-file.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/test/pummel/test-watch-file.js b/test/pummel/test-watch-file.js index 8fdf6b32b2d78c..8b79ef8ede4a63 100644 --- a/test/pummel/test-watch-file.js +++ b/test/pummel/test-watch-file.js @@ -5,14 +5,11 @@ var assert = require('assert'); var fs = require('fs'); var path = require('path'); -var f = path.join(common.fixturesDir, 'x.txt'); +const f = path.join(common.fixturesDir, 'x.txt'); -console.log('watching for changes of ' + f); - -var changes = 0; +let changes = 0; function watchFile() { - fs.watchFile(f, function(curr, prev) { - console.log(f + ' change'); + fs.watchFile(f, (curr, prev) => { changes++; assert.notDeepStrictEqual(curr.mtime, prev.mtime); fs.unwatchFile(f); @@ -24,7 +21,7 @@ function watchFile() { watchFile(); -var fd = fs.openSync(f, 'w+'); +const fd = fs.openSync(f, 'w+'); fs.writeSync(fd, 'xyz\n'); fs.closeSync(fd); From 4d51db87dcac503bcfcd047d24debd5e88b696f3 Mon Sep 17 00:00:00 2001 From: abouthiroppy Date: Mon, 9 Jan 2017 07:14:16 +0900 Subject: [PATCH 102/148] test: refactor test-doctool-html.js PR-URL: https://github.com/nodejs/node/pull/10696 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Michael Dawson --- test/doctool/test-doctool-html.js | 2 +- test/doctool/test-doctool-json.js | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js index bd21e21d9563d2..1745c8fea3df5c 100644 --- a/test/doctool/test-doctool-html.js +++ b/test/doctool/test-doctool-html.js @@ -74,7 +74,7 @@ const testData = [ }, ]; -testData.forEach(function(item) { +testData.forEach((item) => { // Normalize expected data by stripping whitespace const expected = item.html.replace(/\s/g, ''); diff --git a/test/doctool/test-doctool-json.js b/test/doctool/test-doctool-json.js index 520c79bef8bcda..ae7b2007b7d2ef 100644 --- a/test/doctool/test-doctool-json.js +++ b/test/doctool/test-doctool-json.js @@ -18,7 +18,7 @@ const json = require('../../tools/doc/json.js'); // Test data is a list of objects with two properties. // The file property is the file path. // The json property is some json which will be generated by the doctool. -var testData = [ +const testData = [ { file: path.join(common.fixturesDir, 'sample_document.md'), json: { @@ -136,10 +136,10 @@ var testData = [ } ]; -testData.forEach(function(item) { - fs.readFile(item.file, 'utf8', common.mustCall(function(err, input) { +testData.forEach((item) => { + fs.readFile(item.file, 'utf8', common.mustCall((err, input) => { assert.ifError(err); - json(input, 'foo', common.mustCall(function(err, output) { + json(input, 'foo', common.mustCall((err, output) => { assert.ifError(err); assert.deepStrictEqual(output, item.json); })); From f86c64a13a5e6341a6d866f80f6bf608deb1b6dc Mon Sep 17 00:00:00 2001 From: sivaprasanna Date: Sun, 8 Jan 2017 14:03:09 +0530 Subject: [PATCH 103/148] test: refactor the code of test-keep-alive.js * use const and let instead of var * use assert.strictEqual instead of assert.equal * use arrow functions * removed console.log statements PR-URL: https://github.com/nodejs/node/pull/10684 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani --- test/pummel/test-keep-alive.js | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index 1861b2df970e18..47d529b64082fa 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -12,8 +12,8 @@ if (common.isWindows) { return; } -var body = 'hello world\n'; -var server = http.createServer(function(req, res) { +const body = 'hello world\n'; +const server = http.createServer(function(req, res) { res.writeHead(200, { 'Content-Length': body.length, 'Content-Type': 'text/plain' @@ -22,12 +22,12 @@ var server = http.createServer(function(req, res) { res.end(); }); -var keepAliveReqSec = 0; -var normalReqSec = 0; +let keepAliveReqSec = 0; +let normalReqSec = 0; function runAb(opts, callback) { - var args = [ + const args = [ '-c', opts.concurrent || 100, '-t', opts.threads || 2, '-d', opts.duration || '10s', @@ -41,13 +41,11 @@ function runAb(opts, callback) { args.push(url.format({ hostname: '127.0.0.1', port: common.PORT, protocol: 'http'})); - //console.log(comm, args.join(' ')); - - var child = spawn('wrk', args); + const child = spawn('wrk', args); child.stderr.pipe(process.stderr); child.stdout.setEncoding('utf8'); - var stdout; + let stdout; child.stdout.on('data', function(data) { stdout += data; @@ -60,11 +58,11 @@ function runAb(opts, callback) { return; } - var matches = /Requests\/sec:\s*(\d+)\./mi.exec(stdout); - var reqSec = parseInt(matches[1]); + let matches = /Requests\/sec:\s*(\d+)\./mi.exec(stdout); + const reqSec = parseInt(matches[1]); matches = /Keep-Alive requests:\s*(\d+)/mi.exec(stdout); - var keepAliveRequests; + let keepAliveRequests; if (matches) { keepAliveRequests = parseInt(matches[1]); } else { @@ -75,21 +73,19 @@ function runAb(opts, callback) { }); } -server.listen(common.PORT, function() { - runAb({ keepalive: true }, function(reqSec) { +server.listen(common.PORT, () => { + runAb({ keepalive: true }, (reqSec) => { keepAliveReqSec = reqSec; - console.log('keep-alive:', keepAliveReqSec, 'req/sec'); runAb({ keepalive: false }, function(reqSec) { normalReqSec = reqSec; - console.log('normal:' + normalReqSec + ' req/sec'); server.close(); }); }); }); process.on('exit', function() { - assert.equal(true, normalReqSec > 50); - assert.equal(true, keepAliveReqSec > 50); - assert.equal(true, normalReqSec < keepAliveReqSec); + assert.strictEqual(true, normalReqSec > 50); + assert.strictEqual(true, keepAliveReqSec > 50); + assert.strictEqual(true, normalReqSec < keepAliveReqSec); }); From 279cb09cc3118747b88332f98384655efe56b6b1 Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Sat, 7 Jan 2017 09:25:03 +0200 Subject: [PATCH 104/148] src: enable writev for pipe handles on Unix This commit enables writev for Unix Domain Sockets on supported platforms thus enabling cork/uncork functionality for them and improving IPC performance. Fixes: https://github.com/nodejs/node/issues/5095 PR-URL: https://github.com/nodejs/node/pull/10677 Reviewed-By: Anna Henningsen Reviewed-By: Fedor Indutny Reviewed-By: Trevor Norris Reviewed-By: James M Snell --- src/pipe_wrap.cc | 4 +++ test/parallel/test-pipe-writev.js | 46 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 test/parallel/test-pipe-writev.js diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 5bcb40f5d37fe5..4d7939bdfb10ed 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -82,7 +82,11 @@ void PipeWrap::Initialize(Local target, env->SetProtoMethod(t, "unref", HandleWrap::Unref); env->SetProtoMethod(t, "ref", HandleWrap::Ref); +#ifdef _WIN32 StreamWrap::AddMethods(env, t); +#else + StreamWrap::AddMethods(env, t, StreamBase::kFlagHasWritev); +#endif env->SetProtoMethod(t, "bind", Bind); env->SetProtoMethod(t, "listen", Listen); diff --git a/test/parallel/test-pipe-writev.js b/test/parallel/test-pipe-writev.js new file mode 100644 index 00000000000000..6440b5f623761d --- /dev/null +++ b/test/parallel/test-pipe-writev.js @@ -0,0 +1,46 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); + +if (common.isWindows) { + common.skip('Unix-specific test'); + return; +} + +common.refreshTmpDir(); + +const server = net.createServer((connection) => { + connection.on('error', (err) => { + throw err; + }); + + const writev = connection._writev.bind(connection); + connection._writev = common.mustCall(writev); + + connection.cork(); + connection.write('pi'); + connection.write('ng'); + connection.end(); +}); + +server.on('error', (err) => { + throw err; +}); + +server.listen(common.PIPE, () => { + const client = net.connect(common.PIPE); + + client.on('error', (err) => { + throw err; + }); + + client.on('data', common.mustCall((data) => { + assert.strictEqual(data.toString(), 'ping'); + })); + + client.on('end', () => { + server.close(); + }); +}); From 626875f2e41f4fb1dcfa6df91a46f3d8742cf12e Mon Sep 17 00:00:00 2001 From: Brian White Date: Wed, 11 Jan 2017 23:30:24 -0500 Subject: [PATCH 105/148] benchmark: don't lint autogenerated modules PR-URL: https://github.com/nodejs/node/pull/10756 Reviewed-By: Rich Trott Reviewed-By: Teddy Katz Reviewed-By: James M Snell Reviewed-By: Gibson Fahnestock Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- .eslintignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.eslintignore b/.eslintignore index 6791fbf312a08b..1ccb8f831baa0b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -6,3 +6,4 @@ test/disabled test/tmp*/ tools/eslint node_modules +benchmark/tmp/ From 9abde3ac6e9c80da17ccb8c06eefe5b69ef55930 Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Tue, 10 Jan 2017 13:43:08 +0000 Subject: [PATCH 106/148] test: use realpath for NODE_TEST_DIR in common.js If you don't specify NODE_TEST_DIR, common.tmpDir will resolve to the realpath of `node/test`. If you do specify NODE_TEST_DIR (with the environment variable or by running or by running tools/test.py --test-dir=x), common.tmpDir (which is resolved from testRoot) uses the symbolic path (doesn't resolve symlinks). This uses fs.realpathSync() to fix that. PR-URL: https://github.com/nodejs/node/pull/10723 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Michael Dawson --- test/common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/common.js b/test/common.js index 17d83117908501..3813b07998cb6c 100644 --- a/test/common.js +++ b/test/common.js @@ -9,7 +9,7 @@ const stream = require('stream'); const util = require('util'); const testRoot = process.env.NODE_TEST_DIR ? - path.resolve(process.env.NODE_TEST_DIR) : __dirname; + fs.realpathSync(process.env.NODE_TEST_DIR) : __dirname; exports.testDir = __dirname; exports.fixturesDir = path.join(exports.testDir, 'fixtures'); From 6e7dfb1f452ec2927f667c65abef379872d35840 Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Tue, 10 Jan 2017 15:36:07 +0000 Subject: [PATCH 107/148] test: fix temp-dir option in tools/test.py If a temp-dir is specified and already exists, the NODE_TEST_DIR environment variable will never be set. This fixes that. PR-URL: https://github.com/nodejs/node/pull/10723 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Michael Dawson --- tools/test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/test.py b/tools/test.py index 42f25ae52201e5..735f8550316a0a 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1672,9 +1672,9 @@ def Main(): tempdir = os.environ.get('NODE_TEST_DIR') or options.temp_dir if tempdir: + os.environ['NODE_TEST_DIR'] = tempdir try: os.makedirs(tempdir) - os.environ['NODE_TEST_DIR'] = tempdir except OSError as exception: if exception.errno != errno.EEXIST: print "Could not create the temporary directory", options.temp_dir From 396688f075a9b052c75436e45858f9ff45b22247 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Mon, 18 Jan 2016 17:51:15 +0800 Subject: [PATCH 108/148] readline: refactor construct Interface Remove the dependency on the arguments.length. PR-URL: https://github.com/nodejs/node/pull/4740 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Trevor Norris Reviewed-By: Benjamin Gruenbaum --- lib/readline.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/readline.js b/lib/readline.js index 546dfb173eb8fa..66ba46da354ff8 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -17,22 +17,13 @@ const EventEmitter = require('events'); exports.createInterface = function(input, output, completer, terminal) { - var rl; - if (arguments.length === 1) { - rl = new Interface(input); - } else { - rl = new Interface(input, output, completer, terminal); - } - return rl; + return new Interface(input, output, completer, terminal); }; function Interface(input, output, completer, terminal) { if (!(this instanceof Interface)) { - // call the constructor preserving original number of arguments - const self = Object.create(Interface.prototype); - Interface.apply(self, arguments); - return self; + return new Interface(input, output, completer, terminal); } this._sawReturn = false; @@ -41,7 +32,7 @@ function Interface(input, output, completer, terminal) { EventEmitter.call(this); var historySize; - if (arguments.length === 1) { + if (input && input.input) { // an options object was given output = input.output; completer = input.completer; From b3d1700d1f8d31551ecfcab7560e91e40511337e Mon Sep 17 00:00:00 2001 From: Chase Starr Date: Wed, 11 Jan 2017 19:45:23 -0800 Subject: [PATCH 109/148] test: improve tests in pummel/test-exec * add asset.strictEqual to stdout and stderr. Fixes no-unused-vars. * replace double quotes with single PR-URL: https://github.com/nodejs/node/pull/10757 Reviewed-By: Rich Trott Reviewed-By: James M Snell Reviewed-By: Gibson Fahnestock Reviewed-By: Michael Dawson --- test/pummel/test-exec.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/pummel/test-exec.js b/test/pummel/test-exec.js index 6f6e1511b14442..18404373318917 100644 --- a/test/pummel/test-exec.js +++ b/test/pummel/test-exec.js @@ -63,6 +63,8 @@ exec(SLEEP3_COMMAND, { timeout: 50 }, function(err, stdout, stderr) { assert.ok(err); assert.ok(err.killed); assert.strictEqual(err.signal, 'SIGTERM'); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, ''); }); @@ -85,6 +87,8 @@ function killMeTwiceCallback(err, stdout, stderr) { assert.ok(err); assert.ok(err.killed); assert.strictEqual(err.signal, 'SIGTERM'); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, ''); // the timeout should still be in effect console.log('\'sleep 3\' was already killed. Took %d ms', diff); @@ -96,6 +100,8 @@ exec('python -c "print 200000*\'C\'"', {maxBuffer: 1000}, function(err, stdout, stderr) { assert.ok(err); assert.ok(/maxBuffer/.test(err.message)); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, ''); }); From 725a89606b1d7e3383457ae0ab8f3246b48bb741 Mon Sep 17 00:00:00 2001 From: Javis Sullivan Date: Wed, 11 Jan 2017 09:48:46 -0500 Subject: [PATCH 110/148] doc: remove duplicate properties bullet in readme PR-URL: https://github.com/nodejs/node/pull/10741 Reviewed-By: Sam Roberts Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca --- tools/doc/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/doc/README.md b/tools/doc/README.md index e472c712dc0a52..1aa2158d14209f 100644 --- a/tools/doc/README.md +++ b/tools/doc/README.md @@ -98,10 +98,9 @@ Each type of heading has a description block. This event is emitted on instances of SomeClass, not on the module itself. -* Modules have (description, Properties, Functions, Classes, Examples) -* Properties have (type, description) -* Functions have (list of arguments, description) * Classes have (description, Properties, Methods, Events) * Events have (list of arguments, description) +* Functions have (list of arguments, description) * Methods have (list of arguments, description) +* Modules have (description, Properties, Functions, Classes, Examples) * Properties have (type, description) From 53b0f413cd5346cf392f9b92d267501afcc0a950 Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Wed, 11 Jan 2017 21:10:18 -0500 Subject: [PATCH 111/148] test: improve the code in test-process-cpuUsage * validate the errors for assert.throws * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10714 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-process-cpuUsage.js | 54 ++++++++++++++++++++------ 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-process-cpuUsage.js b/test/parallel/test-process-cpuUsage.js index 92dc71918585c3..0c553c576a1f25 100644 --- a/test/parallel/test-process-cpuUsage.js +++ b/test/parallel/test-process-cpuUsage.js @@ -33,27 +33,57 @@ for (let i = 0; i < 10; i++) { assert(diffUsage.system >= 0); } +const invalidUserArgument = + /^TypeError: value of user property of argument is invalid$/; +const invalidSystemArgument = + /^TypeError: value of system property of argument is invalid$/; + // Ensure that an invalid shape for the previous value argument throws an error. -assert.throws(function() { process.cpuUsage(1); }); -assert.throws(function() { process.cpuUsage({}); }); -assert.throws(function() { process.cpuUsage({ user: 'a' }); }); -assert.throws(function() { process.cpuUsage({ system: 'b' }); }); -assert.throws(function() { process.cpuUsage({ user: null, system: 'c' }); }); -assert.throws(function() { process.cpuUsage({ user: 'd', system: null }); }); -assert.throws(function() { process.cpuUsage({ user: -1, system: 2 }); }); -assert.throws(function() { process.cpuUsage({ user: 3, system: -2 }); }); -assert.throws(function() { +assert.throws(() => { + process.cpuUsage(1); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({}); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({ user: 'a' }); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({ system: 'b' }); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({ user: null, system: 'c' }); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({ user: 'd', system: null }); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({ user: -1, system: 2 }); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({ user: 3, system: -2 }); +}, invalidSystemArgument); + +assert.throws(() => { process.cpuUsage({ user: Number.POSITIVE_INFINITY, system: 4 }); -}); -assert.throws(function() { +}, invalidUserArgument); + +assert.throws(() => { process.cpuUsage({ user: 5, system: Number.NEGATIVE_INFINITY }); -}); +}, invalidSystemArgument); // Ensure that the return value is the expected shape. function validateResult(result) { From af3c21197de5bc0b27a77ef1f647bda265393b76 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 17 Jan 2017 07:51:25 +0100 Subject: [PATCH 112/148] build: move source files from headers section Currently, the sources list contains sources and headers which are separated by a comment. I noticed two .cc files after the headers comment and this commit moves those files the start of the list where the rest of source files are. PR-URL: https://github.com/nodejs/node/pull/10850 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Italo A. Casas --- node.gyp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node.gyp b/node.gyp index 1c10630f88bdb9..cccc8a32980d01 100644 --- a/node.gyp +++ b/node.gyp @@ -163,6 +163,7 @@ 'src/signal_wrap.cc', 'src/spawn_sync.cc', 'src/string_bytes.cc', + 'src/string_search.cc', 'src/stream_base.cc', 'src/stream_wrap.cc', 'src/tcp_wrap.cc', @@ -170,6 +171,7 @@ 'src/tty_wrap.cc', 'src/process_wrap.cc', 'src/udp_wrap.cc', + 'src/util.cc', 'src/uv.cc', # headers to make for a more pleasant IDE experience 'src/async-wrap.h', @@ -208,8 +210,6 @@ 'src/tree.h', 'src/util.h', 'src/util-inl.h', - 'src/util.cc', - 'src/string_search.cc', 'deps/http_parser/http_parser.h', 'deps/v8/include/v8.h', 'deps/v8/include/v8-debug.h', From 89e9da6b6d5c2aa3d3469744c54b8b5248e3ca4b Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 17 Jan 2017 12:58:37 +0200 Subject: [PATCH 113/148] test: tests for _readableStream.awaitDrain Fixes: https://github.com/nodejs/node/issues/8684 PR-URL: https://github.com/nodejs/node/pull/8914 Reviewed-By: Matteo Collina --- ...t-stream-pipe-await-drain-manual-resume.js | 16 ++++++++++++++ ...tream-pipe-await-drain-push-while-write.js | 22 +++++++++++++++++-- test/parallel/test-stream-pipe-await-drain.js | 19 ++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-stream-pipe-await-drain-manual-resume.js b/test/parallel/test-stream-pipe-await-drain-manual-resume.js index d26741b8bb4825..f7bff02bb1658a 100644 --- a/test/parallel/test-stream-pipe-await-drain-manual-resume.js +++ b/test/parallel/test-stream-pipe-await-drain-manual-resume.js @@ -1,6 +1,7 @@ 'use strict'; const common = require('../common'); const stream = require('stream'); +const assert = require('assert'); // A consumer stream with a very low highWaterMark, which starts in a state // where it buffers the chunk it receives rather than indicating that they @@ -26,6 +27,11 @@ const readable = new stream.Readable({ readable.pipe(writable); readable.once('pause', common.mustCall(() => { + assert.strictEqual( + readable._readableState.awaitDrain, + 1, + 'awaitDrain doesn\'t increase' + ); // First pause, resume manually. The next write() to writable will still // return false, because chunks are still being buffered, so it will increase // the awaitDrain counter again. @@ -34,6 +40,11 @@ readable.once('pause', common.mustCall(() => { })); readable.once('pause', common.mustCall(() => { + assert.strictEqual( + readable._readableState.awaitDrain, + 1, + '.resume() does not reset counter' + ); // Second pause, handle all chunks from now on. Once all callbacks that // are currently queued up are handled, the awaitDrain drain counter should // fall back to 0 and all chunks that are pending on the readable side @@ -50,5 +61,10 @@ readable.push(Buffer(100)); // Should get through to the writable. readable.push(null); writable.on('finish', common.mustCall(() => { + assert.strictEqual( + readable._readableState.awaitDrain, + 0, + 'awaitDrain not 0 after all chunks are written' + ); // Everything okay, all chunks were written. })); diff --git a/test/parallel/test-stream-pipe-await-drain-push-while-write.js b/test/parallel/test-stream-pipe-await-drain-push-while-write.js index 1dfdfdb80c8d71..67a8f304c31614 100644 --- a/test/parallel/test-stream-pipe-await-drain-push-while-write.js +++ b/test/parallel/test-stream-pipe-await-drain-push-while-write.js @@ -1,16 +1,34 @@ 'use strict'; const common = require('../common'); const stream = require('stream'); +const assert = require('assert'); + +const awaitDrainStates = [ + 1, // after first chunk before callback + 1, // after second chunk before callback + 0 // resolving chunk pushed after first chunk, awaitDrain is decreased +]; // A writable stream which pushes data onto the stream which pipes into it, // but only the first time it's written to. Since it's not paused at this time, // a second write will occur. If the pipe increases awaitDrain twice, we'll // never get subsequent chunks because 'drain' is only emitted once. const writable = new stream.Writable({ - write: common.mustCall((chunk, encoding, cb) => { + write: common.mustCall(function(chunk, encoding, cb) { if (chunk.length === 32 * 1024) { // first chunk - readable.push(new Buffer(33 * 1024)); // above hwm + const beforePush = readable._readableState.awaitDrain; + readable.push(new Buffer(34 * 1024)); // above hwm + // We should check if awaitDrain counter is increased. + const afterPush = readable._readableState.awaitDrain; + assert.strictEqual(afterPush - beforePush, 1, + 'Counter is not increased for awaitDrain'); } + + assert.strictEqual( + awaitDrainStates.shift(), + readable._readableState.awaitDrain, + 'State variable awaitDrain is not correct.' + ); cb(); }, 3) }); diff --git a/test/parallel/test-stream-pipe-await-drain.js b/test/parallel/test-stream-pipe-await-drain.js index 0e8d3497123538..ff232157c6cbe0 100644 --- a/test/parallel/test-stream-pipe-await-drain.js +++ b/test/parallel/test-stream-pipe-await-drain.js @@ -1,12 +1,14 @@ 'use strict'; const common = require('../common'); const stream = require('stream'); +const assert = require('assert'); // This is very similar to test-stream-pipe-cleanup-pause.js. const reader = new stream.Readable(); const writer1 = new stream.Writable(); const writer2 = new stream.Writable(); +const writer3 = new stream.Writable(); // 560000 is chosen here because it is larger than the (default) highWaterMark // and will cause `.write()` to return false @@ -19,7 +21,10 @@ writer1._write = common.mustCall(function(chunk, encoding, cb) { this.emit('chunk-received'); cb(); }, 1); + writer1.once('chunk-received', function() { + assert.strictEqual(reader._readableState.awaitDrain, 0, + 'initial value is not 0'); setImmediate(function() { // This one should *not* get through to writer1 because writer2 is not // "done" processing. @@ -29,12 +34,26 @@ writer1.once('chunk-received', function() { // A "slow" consumer: writer2._write = common.mustCall(function(chunk, encoding, cb) { + assert.strictEqual( + reader._readableState.awaitDrain, 1, + 'awaitDrain isn\'t 1 after first push' + ); // Not calling cb here to "simulate" slow stream. + // This should be called exactly once, since the first .write() call + // will return false. +}, 1); +writer3._write = common.mustCall(function(chunk, encoding, cb) { + assert.strictEqual( + reader._readableState.awaitDrain, 2, + 'awaitDrain isn\'t 2 after second push' + ); + // Not calling cb here to "simulate" slow stream. // This should be called exactly once, since the first .write() call // will return false. }, 1); reader.pipe(writer1); reader.pipe(writer2); +reader.pipe(writer3); reader.push(buffer); From 1c223ecc706106b09a06327404d2ba5de41c8a9c Mon Sep 17 00:00:00 2001 From: abouthiroppy Date: Mon, 16 Jan 2017 15:49:48 +0900 Subject: [PATCH 114/148] test: add http-common's test PR-URL: https://github.com/nodejs/node/pull/10832 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca --- test/parallel/test-http-common.js | 33 +++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/parallel/test-http-common.js diff --git a/test/parallel/test-http-common.js b/test/parallel/test-http-common.js new file mode 100644 index 00000000000000..1629856ce57d09 --- /dev/null +++ b/test/parallel/test-http-common.js @@ -0,0 +1,33 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const httpCommon = require('_http_common'); +const checkIsHttpToken = httpCommon._checkIsHttpToken; +const checkInvalidHeaderChar = httpCommon._checkInvalidHeaderChar; + +// checkIsHttpToken +assert(checkIsHttpToken('t')); +assert(checkIsHttpToken('tt')); +assert(checkIsHttpToken('ttt')); +assert(checkIsHttpToken('tttt')); +assert(checkIsHttpToken('ttttt')); + +assert.strictEqual(checkIsHttpToken(''), false); +assert.strictEqual(checkIsHttpToken(' '), false); +assert.strictEqual(checkIsHttpToken('あ'), false); +assert.strictEqual(checkIsHttpToken('あa'), false); +assert.strictEqual(checkIsHttpToken('aaaaあaaaa'), false); + +// checkInvalidHeaderChar +assert(checkInvalidHeaderChar('あ')); +assert(checkInvalidHeaderChar('aaaaあaaaa')); + +assert.strictEqual(checkInvalidHeaderChar(''), false); +assert.strictEqual(checkInvalidHeaderChar(1), false); +assert.strictEqual(checkInvalidHeaderChar(' '), false); +assert.strictEqual(checkInvalidHeaderChar(false), false); +assert.strictEqual(checkInvalidHeaderChar('t'), false); +assert.strictEqual(checkInvalidHeaderChar('tt'), false); +assert.strictEqual(checkInvalidHeaderChar('ttt'), false); +assert.strictEqual(checkInvalidHeaderChar('tttt'), false); +assert.strictEqual(checkInvalidHeaderChar('ttttt'), false); From 7bceb4fb48018daf2d18723b0a22d7bb53dd52f0 Mon Sep 17 00:00:00 2001 From: Travis Meisenheimer Date: Wed, 18 Jan 2017 20:57:12 -0600 Subject: [PATCH 115/148] test: add message verification on assert.throws MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add regular expression for error message validation to instances of assert.throws() in test-assert.js. PR-URL: https://github.com/nodejs/node/pull/10890 Reviewed-By: Rich Trott Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: Colin Ihrig --- test/parallel/test-assert.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 563f67e91e07a8..6eddd9534958a9 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -92,11 +92,16 @@ assert.doesNotThrow(makeBlock(a.deepEqual, /a/g, /a/g)); assert.doesNotThrow(makeBlock(a.deepEqual, /a/i, /a/i)); assert.doesNotThrow(makeBlock(a.deepEqual, /a/m, /a/m)); assert.doesNotThrow(makeBlock(a.deepEqual, /a/igm, /a/igm)); -assert.throws(makeBlock(a.deepEqual, /ab/, /a/)); -assert.throws(makeBlock(a.deepEqual, /a/g, /a/)); -assert.throws(makeBlock(a.deepEqual, /a/i, /a/)); -assert.throws(makeBlock(a.deepEqual, /a/m, /a/)); -assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im)); +assert.throws(makeBlock(a.deepEqual, /ab/, /a/), + /^AssertionError: \/ab\/ deepEqual \/a\/$/); +assert.throws(makeBlock(a.deepEqual, /a/g, /a/), + /^AssertionError: \/a\/g deepEqual \/a\/$/); +assert.throws(makeBlock(a.deepEqual, /a/i, /a/), + /^AssertionError: \/a\/i deepEqual \/a\/$/); +assert.throws(makeBlock(a.deepEqual, /a/m, /a/), + /^AssertionError: \/a\/m deepEqual \/a\/$/); +assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im), + /^AssertionError: \/a\/gim deepEqual \/a\/im$/); { const re1 = /a/g; From 9c53e402d7dd76b3607cc513895416835f133035 Mon Sep 17 00:00:00 2001 From: Adam Langley Date: Tue, 17 Jan 2017 12:04:40 -0800 Subject: [PATCH 116/148] crypto: freelist_max_len is gone in OpenSSL 1.1.0 The freelist_max_len member of SSL* (and the freelist itself) has been removed in OpenSSL 1.1.0. Thus this change will be necessary at some point but, for now, it makes it a little easier to build with 1.1.0 without breaking anything for previous versions of OpenSSL. PR-URL: https://github.com/nodejs/node/pull/10859 Reviewed-By: Sam Roberts Reviewed-By: Fedor Indutny Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Shigeki Ohtsu --- lib/_tls_common.js | 4 +++- src/node_crypto.cc | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/_tls_common.js b/lib/_tls_common.js index fbf1d92c983115..dd267bd099352a 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -135,7 +135,9 @@ exports.createSecureContext = function createSecureContext(options, context) { } } - // Do not keep read/write buffers in free list + // Do not keep read/write buffers in free list for OpenSSL < 1.1.0. (For + // OpenSSL 1.1.0, buffers are malloced and freed without the use of a + // freelist.) if (options.singleUse) { c.singleUse = true; c.context.setFreeListLength(0); diff --git a/src/node_crypto.cc b/src/node_crypto.cc index eac56c7ff0f419..ca5b656817d1ec 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -1149,10 +1149,14 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo& args) { void SecureContext::SetFreeListLength(const FunctionCallbackInfo& args) { +#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL) + // |freelist_max_len| was removed in OpenSSL 1.1.0. In that version OpenSSL + // mallocs and frees buffers directly, without the use of a freelist. SecureContext* wrap; ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); wrap->ctx_->freelist_max_len = args[0]->Int32Value(); +#endif } From 90d8e118fbc1ed317828737abf83cd6da36d701e Mon Sep 17 00:00:00 2001 From: Alexey Orlenko Date: Sat, 21 Jan 2017 06:40:49 +0200 Subject: [PATCH 117/148] src: add a missing space in node_os.cc This commit makes a small stylistic fix adding a missing space in GetOSType function in node_os.cc PR-URL: https://github.com/nodejs/node/pull/10931 Reviewed-By: Anna Henningsen Reviewed-By: Michal Zasso Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- src/node_os.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/node_os.cc b/src/node_os.cc index fb62c768a4e31f..389064610c7923 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -67,7 +67,7 @@ static void GetOSType(const FunctionCallbackInfo& args) { } rval = info.sysname; #else // __MINGW32__ - rval ="Windows_NT"; + rval = "Windows_NT"; #endif // __POSIX__ args.GetReturnValue().Set(OneByteString(env->isolate(), rval)); From df69c2148a0e521a575beedf69a290f6cce1c4cc Mon Sep 17 00:00:00 2001 From: John Barboza Date: Fri, 16 Dec 2016 10:46:20 -0500 Subject: [PATCH 118/148] test: check fd 0,1,2 are used, not access mode Don't do a write on stdout/stderr because that checks for their writability. But fd=1 could legitimately be opened with read-only access by the user. All this test needs to ensure is that they are used at startup. PR-URL: https://github.com/nodejs/node/pull/10339 Fixes: https://github.com/nodejs/node/issues/10234 Reviewed-By: Sam Roberts Reviewed-By: Gibson Fahnestock Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell --- test/parallel/test-stdio-closed.js | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-stdio-closed.js b/test/parallel/test-stdio-closed.js index a85467f76a6d0f..98e4f980d50dd6 100644 --- a/test/parallel/test-stdio-closed.js +++ b/test/parallel/test-stdio-closed.js @@ -2,6 +2,7 @@ const common = require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; +const fs = require('fs'); if (common.isWindows) { common.skip('platform not supported.'); @@ -9,21 +10,7 @@ if (common.isWindows) { } if (process.argv[2] === 'child') { - try { - process.stdout.write('stdout', function() { - try { - process.stderr.write('stderr', function() { - process.exit(42); - }); - } catch (e) { - process.exit(84); - } - }); - } catch (e) { - assert.strictEqual(e.code, 'EBADF'); - assert.strictEqual(e.message, 'EBADF: bad file descriptor, write'); - process.exit(126); - } + [0, 1, 2].forEach((i) => assert.doesNotThrow(() => fs.fstatSync(i))); return; } @@ -32,5 +19,5 @@ const cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`; const proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' }); proc.on('exit', common.mustCall(function(exitCode) { - assert.strictEqual(exitCode, common.isAix ? 126 : 42); + assert.strictEqual(exitCode, 0); })); From 56970efe514eb896e4b1a84acdfae2704c0273fc Mon Sep 17 00:00:00 2001 From: abouthiroppy Date: Sat, 21 Jan 2017 21:47:45 +0900 Subject: [PATCH 119/148] test: increase coverage for punycode's decode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added test cases for error. PR-URL: https://github.com/nodejs/node/pull/10940 Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: James M Snell Reviewed-By: Michael Dawson --- test/parallel/test-punycode.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/parallel/test-punycode.js b/test/parallel/test-punycode.js index 0b03a78bd71c7a..80b18f85a98982 100644 --- a/test/parallel/test-punycode.js +++ b/test/parallel/test-punycode.js @@ -18,6 +18,15 @@ assert.strictEqual(punycode.decode( 'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal'), 'Willst du die Blüthe des frühen, die Früchte des späteren Jahres'); assert.strictEqual(punycode.decode('wgv71a119e'), '日本語'); +assert.throws(() => { + punycode.decode(' '); +}, /^RangeError: Invalid input$/); +assert.throws(() => { + punycode.decode('α-'); +}, /^RangeError: Illegal input >= 0x80 \(not a basic code point\)$/); +assert.throws(() => { + punycode.decode('あ'); +}, /^RangeError: Overflow: input needs wider integers to process$/); // http://tools.ietf.org/html/rfc3492#section-7.1 const tests = [ From b3a8e95af34f1d408b2c4f976b5beb0ebc24bd54 Mon Sep 17 00:00:00 2001 From: richnologies Date: Fri, 20 Jan 2017 12:51:55 +0100 Subject: [PATCH 120/148] test: improve test-assert MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add RegExp to check assert throws the expected AssertionErrors. For the one with multiple flags is ok to hardcode the flags since the spec indicates the ordering will always be `gim`: Refs: http://www.ecma-international.org/ecma-262/6.0/#sec-get-regexp.prototype.flags PR-URL: https://github.com/nodejs/node/pull/10916 Reviewed-By: Colin Ihrig Reviewed-By: Michaël Zasso Reviewed-By: Italo A. Casas Reviewed-By: Rich Trott Reviewed-By: James M Snell --- test/parallel/test-assert.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 6eddd9534958a9..0d4b90dc3ad0ad 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -218,11 +218,26 @@ assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/g, /a/g)); assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/i, /a/i)); assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/m, /a/m)); assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/igm, /a/igm)); -assert.throws(makeBlock(a.deepStrictEqual, /ab/, /a/)); -assert.throws(makeBlock(a.deepStrictEqual, /a/g, /a/)); -assert.throws(makeBlock(a.deepStrictEqual, /a/i, /a/)); -assert.throws(makeBlock(a.deepStrictEqual, /a/m, /a/)); -assert.throws(makeBlock(a.deepStrictEqual, /a/igm, /a/im)); +assert.throws( + makeBlock(a.deepStrictEqual, /ab/, /a/), + /^AssertionError: \/ab\/ deepStrictEqual \/a\/$/ +); +assert.throws( + makeBlock(a.deepStrictEqual, /a/g, /a/), + /^AssertionError: \/a\/g deepStrictEqual \/a\/$/ +); +assert.throws( + makeBlock(a.deepStrictEqual, /a/i, /a/), + /^AssertionError: \/a\/i deepStrictEqual \/a\/$/ +); +assert.throws( + makeBlock(a.deepStrictEqual, /a/m, /a/), + /^AssertionError: \/a\/m deepStrictEqual \/a\/$/ +); +assert.throws( + makeBlock(a.deepStrictEqual, /a/igm, /a/im), + /^AssertionError: \/a\/gim deepStrictEqual \/a\/im$/ +); { const re1 = /a/; From 22c25dee9224a89854b86a91006f9d7506ffcb6a Mon Sep 17 00:00:00 2001 From: Brian White Date: Thu, 19 Jan 2017 02:55:21 -0500 Subject: [PATCH 121/148] buffer: improve toJSON() performance PR-URL: https://github.com/nodejs/node/pull/10895 Reviewed-By: Luigi Pinca Reviewed-By: Michal Zasso Reviewed-By: Evan Lucas Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- benchmark/buffers/buffer-tojson.js | 18 ++++++++++++++++++ lib/buffer.js | 12 ++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 benchmark/buffers/buffer-tojson.js diff --git a/benchmark/buffers/buffer-tojson.js b/benchmark/buffers/buffer-tojson.js new file mode 100644 index 00000000000000..1be59952c3fe60 --- /dev/null +++ b/benchmark/buffers/buffer-tojson.js @@ -0,0 +1,18 @@ +'use strict'; + +const common = require('../common.js'); + +const bench = common.createBenchmark(main, { + n: [1e4], + len: [0, 10, 256, 4 * 1024] +}); + +function main(conf) { + var n = +conf.n; + var buf = Buffer.allocUnsafe(+conf.len); + + bench.start(); + for (var i = 0; i < n; ++i) + buf.toJSON(); + bench.end(n); +} diff --git a/lib/buffer.js b/lib/buffer.js index 7bad03939f5e5e..db269f5b9931a6 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -677,10 +677,14 @@ Buffer.prototype.write = function(string, offset, length, encoding) { Buffer.prototype.toJSON = function() { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this, 0) - }; + if (this.length) { + const data = []; + for (var i = 0; i < this.length; ++i) + data[i] = this[i]; + return { type: 'Buffer', data }; + } else { + return { type: 'Buffer', data: [] }; + } }; From a1a850f0665b975395a164be621f313a0ba13f7d Mon Sep 17 00:00:00 2001 From: Gibson Fahnestock Date: Tue, 17 Jan 2017 10:30:43 +0000 Subject: [PATCH 122/148] test: don't connect to :: (use localhost instead) If a test does http.listen(0) or net.listen(0), http.listen(0).address().address returns '::'. Some machines will resolve this to localhost, but not all. Every machine should have localhost defined in /etc/hosts (or equivalent), so it should always resolve. Fixes: https://github.com/nodejs/node/issues/7291 --- test/gc/test-net-timeout.js | 2 +- test/parallel/test-http-status-reason-invalid-chars.js | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js index 7d580f8f2356a4..7e1655f4e6c4a7 100644 --- a/test/gc/test-net-timeout.js +++ b/test/gc/test-net-timeout.js @@ -36,7 +36,7 @@ function getall() { return; (function() { - var req = net.connect(server.address().port, server.address().address); + var req = net.connect(server.address().port); req.resume(); req.setTimeout(10, function() { //console.log('timeout (expected)') diff --git a/test/parallel/test-http-status-reason-invalid-chars.js b/test/parallel/test-http-status-reason-invalid-chars.js index 9950eeeee9cdd2..75ccb2c2430c53 100644 --- a/test/parallel/test-http-status-reason-invalid-chars.js +++ b/test/parallel/test-http-status-reason-invalid-chars.js @@ -3,7 +3,6 @@ const common = require('../common'); const assert = require('assert'); const http = require('http'); -const net = require('net'); function explicit(req, res) { assert.throws(() => { @@ -34,8 +33,7 @@ const server = http.createServer((req, res) => { implicit(req, res); } }).listen(0, common.mustCall(() => { - const addr = server.address().address; - const hostname = net.isIPv6(addr) ? `[${addr}1]` : addr; + const hostname = 'localhost'; const url = `http://${hostname}:${server.address().port}`; let left = 2; const check = common.mustCall((res) => { From db60d92e1581b85760bc62438fe2a78ab83921f3 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Fri, 20 Jan 2017 11:11:45 -0800 Subject: [PATCH 123/148] test: test hmac binding robustness The Hmac binding layer is not documented as part of the API, and is not intended to be used, but it should be robust to misuse, and contains defensive checks for misuse. This test checks that updates without init throw (as opposed to abort or misbehave in some other way). PR-URL: https://github.com/nodejs/node/pull/10923 Reviewed-By: Colin Ihrig Reviewed-By: Rich Trott Reviewed-By: James M Snell --- test/parallel/test-crypto-hmac.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/parallel/test-crypto-hmac.js b/test/parallel/test-crypto-hmac.js index 8b133c0f459674..d83e1cc649a877 100644 --- a/test/parallel/test-crypto-hmac.js +++ b/test/parallel/test-crypto-hmac.js @@ -8,6 +8,14 @@ if (!common.hasCrypto) { } var crypto = require('crypto'); +// Test for binding layer robustness +{ + const binding = process.binding('crypto'); + const h = new binding.Hmac(); + // Fail to init the Hmac with an algorithm. + assert.throws(() => h.update('hello'), /^TypeError: HmacUpdate fail$/); +} + // Test HMAC var h1 = crypto.createHmac('sha1', 'Node') .update('some data') From e607ff52fa52b43c92f57734e77c08c7f5590bbc Mon Sep 17 00:00:00 2001 From: Sakthipriyan Vairamani Date: Wed, 13 Jul 2016 09:27:40 +0530 Subject: [PATCH 124/148] tools: rename eslintrc to an undeprecated format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per ESLint documentation, http://eslint.org/docs/user-guide/configuring#configuration-file-formats the file format .eslintrc is deprecated. This patch just renames the files to .yaml and the structure is already in yaml format. PR-URL: https://github.com/nodejs/node/pull/7699 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson Reviewed-By: Benjamin Gruenbaum Reviewed-By: Michaël Zasso Reviewed-By: Joyee Cheung Reviewed-By: Gibson Fahnestock Reviewed-By: Prince John Wesley Reviewed-By: Johan Bergström Reviewed-By: Rich Trott --- .eslintrc => .eslintrc.yaml | 0 lib/{.eslintrc => .eslintrc.yaml} | 0 test/{.eslintrc => .eslintrc.yaml} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename .eslintrc => .eslintrc.yaml (100%) rename lib/{.eslintrc => .eslintrc.yaml} (100%) rename test/{.eslintrc => .eslintrc.yaml} (100%) diff --git a/.eslintrc b/.eslintrc.yaml similarity index 100% rename from .eslintrc rename to .eslintrc.yaml diff --git a/lib/.eslintrc b/lib/.eslintrc.yaml similarity index 100% rename from lib/.eslintrc rename to lib/.eslintrc.yaml diff --git a/test/.eslintrc b/test/.eslintrc.yaml similarity index 100% rename from test/.eslintrc rename to test/.eslintrc.yaml From a9278a063f2da1e2f0ab75719705296f5b026bf0 Mon Sep 17 00:00:00 2001 From: abouthiroppy Date: Mon, 9 Jan 2017 15:58:37 +0900 Subject: [PATCH 125/148] test: refactor cluster-preload.js PR-URL: https://github.com/nodejs/node/pull/10701 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Italo A. Casas --- test/fixtures/cluster-preload.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/fixtures/cluster-preload.js b/test/fixtures/cluster-preload.js index 6637b418babb0d..f62bc20551c1f4 100644 --- a/test/fixtures/cluster-preload.js +++ b/test/fixtures/cluster-preload.js @@ -4,8 +4,8 @@ var assert = require('assert'); // this module is used as a preload module. It should have a parent with the // module search paths initialized from the current working directory assert.ok(module.parent); -var expectedPaths = require('module')._nodeModulePaths(process.cwd()); -assert.deepEqual(module.parent.paths, expectedPaths); +const expectedPaths = require('module')._nodeModulePaths(process.cwd()); +assert.deepStrictEqual(module.parent.paths, expectedPaths); var cluster = require('cluster'); cluster.isMaster || process.exit(42 + cluster.worker.id); // +42 to distinguish From 9ac2316595e6887bf4da5eb19df44b9776d4a52a Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Sun, 15 Jan 2017 22:23:19 -0500 Subject: [PATCH 126/148] test: improve code in test-http-host-headers * use common.fail to handle errors * remove console.log * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10830 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-http-host-headers.js | 41 ++++++++----------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/test/parallel/test-http-host-headers.js b/test/parallel/test-http-host-headers.js index a9f12d6819314e..863dbae365d164 100644 --- a/test/parallel/test-http-host-headers.js +++ b/test/parallel/test-http-host-headers.js @@ -1,11 +1,10 @@ 'use strict'; -require('../common'); +const common = require('../common'); const http = require('http'); const assert = require('assert'); const httpServer = http.createServer(reqHandler); function reqHandler(req, res) { - console.log('Got request: ' + req.headers.host + ' ' + req.url); if (req.url === '/setHostFalse5') { assert.equal(req.headers.host, undefined); } else { @@ -14,14 +13,9 @@ function reqHandler(req, res) { req.headers.host); } res.writeHead(200, {}); - //process.nextTick(function() { res.end('ok'); }); res.end('ok'); } -function thrower(er) { - throw er; -} - testHttp(); function testHttp() { @@ -30,61 +24,52 @@ function testHttp() { function cb(res) { counter--; - console.log('back from http request. counter = ' + counter); if (counter === 0) { httpServer.close(); } res.resume(); } - httpServer.listen(0, function(er) { - console.error(`test http server listening on ${this.address().port}`); - - if (er) throw er; - + httpServer.listen(0, (er) => { + assert.ifError(er); http.get({ method: 'GET', path: '/' + (counter++), host: 'localhost', - //agent: false, - port: this.address().port, + port: httpServer.address().port, rejectUnauthorized: false - }, cb).on('error', thrower); + }, cb).on('error', common.fail); http.request({ method: 'GET', path: '/' + (counter++), host: 'localhost', - //agent: false, - port: this.address().port, + port: httpServer.address().port, rejectUnauthorized: false - }, cb).on('error', thrower).end(); + }, cb).on('error', common.fail).end(); http.request({ method: 'POST', path: '/' + (counter++), host: 'localhost', - //agent: false, - port: this.address().port, + port: httpServer.address().port, rejectUnauthorized: false - }, cb).on('error', thrower).end(); + }, cb).on('error', common.fail).end(); http.request({ method: 'PUT', path: '/' + (counter++), host: 'localhost', - //agent: false, - port: this.address().port, + port: httpServer.address().port, rejectUnauthorized: false - }, cb).on('error', thrower).end(); + }, cb).on('error', common.fail).end(); http.request({ method: 'DELETE', path: '/' + (counter++), host: 'localhost', - //agent: false, - port: this.address().port, + port: httpServer.address().port, rejectUnauthorized: false - }, cb).on('error', thrower).end(); + }, cb).on('error', common.fail).end(); }); } From ee27917a651ae0c8868dcdee16c5eb1b375425c3 Mon Sep 17 00:00:00 2001 From: stefan judis Date: Tue, 10 Jan 2017 17:38:48 +0100 Subject: [PATCH 127/148] test: improve test-stream2-large-read-stall * use const instead of var * use assert.strictEqual instead of assert.equal * use common.mustCall instead of process.on( 'exit', fn ) PR-URL: https://github.com/nodejs/node/pull/10725 Reviewed-By: James M Snell Reviewed-By: Italo A. Casas --- test/parallel/test-stream2-large-read-stall.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-stream2-large-read-stall.js b/test/parallel/test-stream2-large-read-stall.js index eb13a184e5908c..dd1034c7ba19d8 100644 --- a/test/parallel/test-stream2-large-read-stall.js +++ b/test/parallel/test-stream2-large-read-stall.js @@ -32,7 +32,9 @@ r.on('readable', function() { rs.length); }); -r.on('end', common.mustCall(function() {})); +r.on('end', common.mustCall(function() { + assert.strictEqual(pushes, PUSHCOUNT + 1); +})); var pushes = 0; function push() { @@ -48,7 +50,3 @@ function push() { if (r.push(new Buffer(PUSHSIZE))) setTimeout(push); } - -process.on('exit', function() { - assert.equal(pushes, PUSHCOUNT + 1); -}); From 1b1ba741c365d3aca6dd61a4b09e75224a37ae6f Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Sat, 14 Jan 2017 19:05:04 -0500 Subject: [PATCH 128/148] test: improve code in test-domain-multi * use common.mustCall to validate functions executions * use common.fail to control error * remove unnecessary variables * remove unnecessary assertions * remove console.log and console.error * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10798 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- test/parallel/test-domain-multi.js | 49 ++++++++---------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/test/parallel/test-domain-multi.js b/test/parallel/test-domain-multi.js index cf85dbca460146..e8c5d4924cb553 100644 --- a/test/parallel/test-domain-multi.js +++ b/test/parallel/test-domain-multi.js @@ -1,26 +1,16 @@ 'use strict'; // Tests of multiple domains happening at once. -require('../common'); -var assert = require('assert'); -var domain = require('domain'); - -var caughtA = false; -var caughtB = false; -var caughtC = false; - +const common = require('../common'); +const domain = require('domain'); +const http = require('http'); var a = domain.create(); a.enter(); // this will be our "root" domain -a.on('error', function(er) { - caughtA = true; - console.log('This should not happen'); - throw er; -}); +a.on('error', common.fail); -var http = require('http'); -var server = http.createServer(function(req, res) { +const server = http.createServer((req, res) => { // child domain of a. var b = domain.create(); a.add(b); @@ -31,47 +21,34 @@ var server = http.createServer(function(req, res) { b.add(req); b.add(res); - b.on('error', function(er) { - caughtB = true; - console.error('Error encountered', er); + b.on('error', common.mustCall((er) => { if (res) { res.writeHead(500); res.end('An error occurred'); } // res.writeHead(500), res.destroy, etc. server.close(); - }); + })); // XXX this bind should not be necessary. // the write cb behavior in http/net should use an // event so that it picks up the domain handling. - res.write('HELLO\n', b.bind(function() { + res.write('HELLO\n', b.bind(() => { throw new Error('this kills domain B, not A'); })); -}).listen(0, function() { - var c = domain.create(); - var req = http.get({ host: 'localhost', port: this.address().port }); +}).listen(0, () => { + const c = domain.create(); + const req = http.get({ host: 'localhost', port: server.address().port }); // add the request to the C domain c.add(req); - req.on('response', function(res) { - console.error('got response'); + req.on('response', (res) => { // add the response object to the C domain c.add(res); res.pipe(process.stdout); }); - c.on('error', function(er) { - caughtC = true; - console.error('Error on c', er.message); - }); -}); - -process.on('exit', function() { - assert.strictEqual(caughtA, false); - assert.strictEqual(caughtB, true); - assert.strictEqual(caughtC, true); - console.log('ok - Errors went where they were supposed to go'); + c.on('error', common.mustCall((er) => { })); }); From 017afd48fdc4813acc89bdced26e54b6b4478702 Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Mon, 16 Jan 2017 21:06:33 -0500 Subject: [PATCH 129/148] test: improve code in test-console-instance * use common.mustCall to validate functions executions * use common.fail to check test fail * improve error validations * remove unnecessary assertions * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10813 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig --- test/parallel/test-console-instance.js | 48 ++++++++++---------------- 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js index 4d2727d96b1a55..ab5e5c9e6b3ce7 100644 --- a/test/parallel/test-console-instance.js +++ b/test/parallel/test-console-instance.js @@ -1,71 +1,59 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const Stream = require('stream'); const Console = require('console').Console; -var called = false; const out = new Stream(); const err = new Stream(); // ensure the Console instance doesn't write to the // process' "stdout" or "stderr" streams -process.stdout.write = process.stderr.write = function() { - throw new Error('write() should not be called!'); -}; +process.stdout.write = process.stderr.write = common.fail; // make sure that the "Console" function exists assert.strictEqual('function', typeof Console); // make sure that the Console constructor throws // when not given a writable stream instance -assert.throws(function() { +assert.throws(() => { new Console(); -}, /Console expects a writable stream/); +}, /^TypeError: Console expects a writable stream instance$/); // Console constructor should throw if stderr exists but is not writable -assert.throws(function() { - out.write = function() {}; +assert.throws(() => { + out.write = () => {}; err.write = undefined; new Console(out, err); -}, /Console expects writable stream instances/); +}, /^TypeError: Console expects writable stream instances$/); -out.write = err.write = function(d) {}; +out.write = err.write = (d) => {}; var c = new Console(out, err); -out.write = err.write = function(d) { +out.write = err.write = common.mustCall((d) => { assert.strictEqual(d, 'test\n'); - called = true; -}; +}, 2); -assert(!called); c.log('test'); -assert(called); - -called = false; c.error('test'); -assert(called); -out.write = function(d) { +out.write = common.mustCall((d) => { assert.strictEqual('{ foo: 1 }\n', d); - called = true; -}; +}); -called = false; c.dir({ foo: 1 }); -assert(called); // ensure that the console functions are bound to the console instance -called = 0; -out.write = function(d) { +let called = 0; +out.write = common.mustCall((d) => { called++; - assert.strictEqual(d, called + ' ' + (called - 1) + ' [ 1, 2, 3 ]\n'); -}; + assert.strictEqual(d, `${called} ${called - 1} [ 1, 2, 3 ]\n`); +}, 3); + [1, 2, 3].forEach(c.log); -assert.strictEqual(3, called); // Console() detects if it is called without `new` keyword -assert.doesNotThrow(function() { +assert.doesNotThrow(() => { Console(out, err); }); From 6c1d82c68a43f5fb54d9d6c2ba67aea2fe864edf Mon Sep 17 00:00:00 2001 From: abouthiroppy Date: Fri, 13 Jan 2017 11:05:35 +0900 Subject: [PATCH 130/148] test: improving coverage for dgram PR-URL: https://github.com/nodejs/node/pull/10783 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- .../parallel/test-dgram-multicast-loopback.js | 12 +++++++++++ test/parallel/test-dgram-multicast-setTTL.js | 20 +++++++++---------- test/parallel/test-dgram-setTTL.js | 17 ++++++++++------ 3 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 test/parallel/test-dgram-multicast-loopback.js diff --git a/test/parallel/test-dgram-multicast-loopback.js b/test/parallel/test-dgram-multicast-loopback.js new file mode 100644 index 00000000000000..01def7e28160cd --- /dev/null +++ b/test/parallel/test-dgram-multicast-loopback.js @@ -0,0 +1,12 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); +const socket = dgram.createSocket('udp4'); + +socket.bind(0); +socket.on('listening', common.mustCall(() => { + const result = socket.setMulticastLoopback(16); + assert.strictEqual(result, 16); + socket.close(); +})); diff --git a/test/parallel/test-dgram-multicast-setTTL.js b/test/parallel/test-dgram-multicast-setTTL.js index 83d482f426bcd4..11b5a0a7635857 100644 --- a/test/parallel/test-dgram-multicast-setTTL.js +++ b/test/parallel/test-dgram-multicast-setTTL.js @@ -1,23 +1,23 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const dgram = require('dgram'); const socket = dgram.createSocket('udp4'); -let thrown = false; socket.bind(0); -socket.on('listening', function() { - socket.setMulticastTTL(16); +socket.on('listening', common.mustCall(() => { + const result = socket.setMulticastTTL(16); + assert.strictEqual(result, 16); //Try to set an invalid TTL (valid ttl is > 0 and < 256) - try { + assert.throws(() => { socket.setMulticastTTL(1000); - } catch (e) { - thrown = true; - } + }, /^Error: setMulticastTTL EINVAL$/); - assert(thrown, 'Setting an invalid multicast TTL should throw some error'); + assert.throws(() => { + socket.setMulticastTTL('foo'); + }, /^TypeError: Argument must be a number$/); //close the socket socket.close(); -}); +})); diff --git a/test/parallel/test-dgram-setTTL.js b/test/parallel/test-dgram-setTTL.js index 9393e53c7f1912..7da3975ad4c3fd 100644 --- a/test/parallel/test-dgram-setTTL.js +++ b/test/parallel/test-dgram-setTTL.js @@ -1,17 +1,22 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const dgram = require('dgram'); const socket = dgram.createSocket('udp4'); socket.bind(0); -socket.on('listening', function() { - var result = socket.setTTL(16); +socket.on('listening', common.mustCall(() => { + const result = socket.setTTL(16); assert.strictEqual(result, 16); - assert.throws(function() { + assert.throws(() => { socket.setTTL('foo'); - }, /Argument must be a number/); + }, /^TypeError: Argument must be a number$/); + + // TTL must be a number from > 0 to < 256 + assert.throws(() => { + socket.setTTL(1000); + }, /^Error: setTTL EINVAL$/); socket.close(); -}); +})); From 4d1f7b1df81047682d1aeb5ecf2d1d8dac3883f7 Mon Sep 17 00:00:00 2001 From: abouthiroppy Date: Thu, 19 Jan 2017 15:36:32 +0900 Subject: [PATCH 131/148] test: add dgram.Socket.prototype.bind's test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test that an error is thrown when bind() is called on an already bound socket. PR-URL: https://github.com/nodejs/node/pull/10894 Reviewed-By: Luigi Pinca Reviewed-By: Colin Ihrig Reviewed-By: Claudio Rodriguez Reviewed-By: James M Snell Reviewed-By: Italo A. Casas Reviewed-By: Michaël Zasso --- test/parallel/test-dgram-bind.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-dgram-bind.js b/test/parallel/test-dgram-bind.js index 0bca97fb294f79..2d11fba6443ad8 100644 --- a/test/parallel/test-dgram-bind.js +++ b/test/parallel/test-dgram-bind.js @@ -1,13 +1,17 @@ 'use strict'; -require('../common'); -var assert = require('assert'); -var dgram = require('dgram'); +const common = require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); var socket = dgram.createSocket('udp4'); -socket.on('listening', function() { +socket.on('listening', common.mustCall(() => { + assert.throws(() => { + socket.bind(); + }, /^Error: Socket is already bound$/); + socket.close(); -}); +})); var result = socket.bind(); // should not throw From d8af5a7431cea1e90f5d06ecaf882929576ce63c Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Thu, 19 Jan 2017 20:40:33 -0500 Subject: [PATCH 132/148] test: improve code in test-crypto-verify MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * use common.mustCall to validate functions executions * use common.fail to check test fail * remove console.log * use arrow functions PR-URL: https://github.com/nodejs/node/pull/10845 Reviewed-By: Colin Ihrig Reviewed-By: Sam Roberts Reviewed-By: Michaël Zasso Reviewed-By: James M Snell --- test/parallel/test-crypto-verify-failure.js | 28 +++++++++------------ 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/test/parallel/test-crypto-verify-failure.js b/test/parallel/test-crypto-verify-failure.js index fdc27215027414..415e13ff64e640 100644 --- a/test/parallel/test-crypto-verify-failure.js +++ b/test/parallel/test-crypto-verify-failure.js @@ -19,36 +19,32 @@ var options = { cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = tls.Server(options, function(socket) { - setImmediate(function() { - console.log('sending'); +const server = tls.Server(options, (socket) => { + setImmediate(() => { verify(); - setImmediate(function() { + setImmediate(() => { socket.destroy(); }); }); }); function verify() { - console.log('verify'); crypto.createVerify('RSA-SHA1') .update('Test') .verify(certPem, 'asdfasdfas', 'base64'); } -server.listen(0, function() { +server.listen(0, common.mustCall(() => { tls.connect({ - port: this.address().port, + port: server.address().port, rejectUnauthorized: false - }, function() { + }, common.mustCall(() => { verify(); - }).on('data', function(data) { - console.log(data); - }).on('error', function(err) { - throw err; - }).on('close', function() { - server.close(); - }).resume(); -}); + })) + .on('error', common.fail) + .on('close', common.mustCall(() => { + server.close(); + })).resume(); +})); server.unref(); From c9a92ff49435653b22d584f20f9eb47ee306cf01 Mon Sep 17 00:00:00 2001 From: Travis Meisenheimer Date: Wed, 18 Jan 2017 21:36:52 -0600 Subject: [PATCH 133/148] crypto: return the retval of HMAC_Update Fixes coverity scan issue 55489. PR-URL: https://github.com/nodejs/node/pull/10891 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Sam Roberts Reviewed-By: Brian White --- src/node_crypto.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index ca5b656817d1ec..7ca97057c0ba12 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -3648,8 +3648,8 @@ void Hmac::HmacInit(const FunctionCallbackInfo& args) { bool Hmac::HmacUpdate(const char* data, int len) { if (!initialised_) return false; - HMAC_Update(&ctx_, reinterpret_cast(data), len); - return true; + int r = HMAC_Update(&ctx_, reinterpret_cast(data), len); + return r == 1; } From 6ca9901d8b94e79a1c5e184b7fa5726c96a33521 Mon Sep 17 00:00:00 2001 From: abouthiroppy Date: Fri, 20 Jan 2017 13:31:28 +0900 Subject: [PATCH 134/148] test: add process.assert's test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/10911 Reviewed-By: Rich Trott Reviewed-By: Colin Ihrig Reviewed-By: Michaël Zasso Reviewed-By: Italo A. Casas Reviewed-By: Luigi Pinca Reviewed-By: James M Snell --- test/parallel/test-process-assert.js | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 test/parallel/test-process-assert.js diff --git a/test/parallel/test-process-assert.js b/test/parallel/test-process-assert.js new file mode 100644 index 00000000000000..e386c3d7600c06 --- /dev/null +++ b/test/parallel/test-process-assert.js @@ -0,0 +1,11 @@ +'use strict'; +require('../common'); +const assert = require('assert'); + +assert.strictEqual(process.assert(1, 'error'), undefined); +assert.throws(() => { + process.assert(undefined, 'errorMessage'); +}, /^Error: errorMessage$/); +assert.throws(() => { + process.assert(false); +}, /^Error: assertion error$/); From 4b83a83c068dc1671d125157d4db744485698eb5 Mon Sep 17 00:00:00 2001 From: Phillip Johnsen Date: Wed, 25 Jan 2017 21:54:34 +0100 Subject: [PATCH 135/148] tools,doc: add Google Analytics tracking. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds Google Analytics tracking script to all doc pages when `DOCS_ANALYTICS` is set when running `make`: ```bash $ DOCS_ANALYTICS= make ``` By default (when `DOCS_ANALYTICS` is not set), no tracking scripts are included. It respects "Do Not Track" settings end users might have in their browser. Also changes make target `doc-upload` from depending on the `$(TARBALL)` target, to only depend on `doc` directly. PR-URL: https://github.com/nodejs/node/pull/6601 Reviewed-By: Johan Bergström Reviewed-By: Rod Vagg Reviewed-By: Sakthipriyan Vairamani --- Makefile | 10 +++++-- doc/api_assets/dnt_helper.js | 49 +++++++++++++++++++++++++++++++ doc/template.html | 1 + test/doctool/test-doctool-html.js | 20 ++++++++++++- tools/doc/generate.js | 12 +++++--- tools/doc/html.js | 25 ++++++++++++++++ 6 files changed, 110 insertions(+), 7 deletions(-) create mode 100644 doc/api_assets/dnt_helper.js diff --git a/Makefile b/Makefile index d6db3878d7b232..61153899e0db1d 100644 --- a/Makefile +++ b/Makefile @@ -280,6 +280,11 @@ test-v8-benchmarks: v8 test-v8-all: test-v8 test-v8-intl test-v8-benchmarks # runs all v8 tests +# Google Analytics ID used for tracking API docs page views, empty +# DOCS_ANALYTICS means no tracking scripts will be included in the +# generated .html files +DOCS_ANALYTICS ?= + apidoc_sources = $(wildcard doc/api/*.md) apidocs_html = $(apidoc_dirs) $(apiassets) $(addprefix out/,$(apidoc_sources:.md=.html)) apidocs_json = $(apidoc_dirs) $(apiassets) $(addprefix out/,$(apidoc_sources:.md=.json)) @@ -313,7 +318,8 @@ out/doc/api/%.json: doc/api/%.md [ -x $(NODE) ] && $(NODE) $(gen-json) || node $(gen-json) # check if ./node is actually set, else use user pre-installed binary -gen-html = tools/doc/generate.js --node-version=$(FULLVERSION) --format=html --template=doc/template.html $< > $@ +gen-html = tools/doc/generate.js --node-version=$(FULLVERSION) --format=html \ + --template=doc/template.html --analytics=$(DOCS_ANALYTICS) $< > $@ out/doc/api/%.html: doc/api/%.md @[ -e tools/doc/node_modules/js-yaml/package.json ] || \ [ -e tools/eslint/node_modules/js-yaml/package.json ] || \ @@ -558,7 +564,7 @@ ifeq ($(XZ), 0) ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION).tar.xz.done" endif -doc-upload: tar +doc-upload: doc ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)" chmod -R ug=rw-x+X,o=r+X out/doc/ scp -pr out/doc/ $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs/ diff --git a/doc/api_assets/dnt_helper.js b/doc/api_assets/dnt_helper.js new file mode 100644 index 00000000000000..f255d916c2df32 --- /dev/null +++ b/doc/api_assets/dnt_helper.js @@ -0,0 +1,49 @@ +/** + * http://schalkneethling.github.io/blog/2015/11/06/respect-user-choice-do-not-track/ + * https://github.com/schalkneethling/dnt-helper/blob/master/js/dnt-helper.js + * + * Returns true or false based on whether doNotTack is enabled. It also takes into account the + * anomalies, such as !bugzilla 887703, which effect versions of Fx 31 and lower. It also handles + * IE versions on Windows 7, 8 and 8.1, where the DNT implementation does not honor the spec. + * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1217896 for more details + * @params {string} [dnt] - An optional mock doNotTrack string to ease unit testing. + * @params {string} [userAgent] - An optional mock userAgent string to ease unit testing. + * @returns {boolean} true if enabled else false + */ +function _dntEnabled(dnt, userAgent) { + + 'use strict'; + + // for old version of IE we need to use the msDoNotTrack property of navigator + // on newer versions, and newer platforms, this is doNotTrack but, on the window object + // Safari also exposes the property on the window object. + var dntStatus = dnt || navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack; + var ua = userAgent || navigator.userAgent; + + // List of Windows versions known to not implement DNT according to the standard. + var anomalousWinVersions = ['Windows NT 6.1', 'Windows NT 6.2', 'Windows NT 6.3']; + + var fxMatch = ua.match(/Firefox\/(\d+)/); + var ieRegEx = /MSIE|Trident/i; + var isIE = ieRegEx.test(ua); + // Matches from Windows up to the first occurance of ; un-greedily + // http://www.regexr.com/3c2el + var platform = ua.match(/Windows.+?(?=;)/g); + + // With old versions of IE, DNT did not exist so we simply return false; + if (isIE && typeof Array.prototype.indexOf !== 'function') { + return false; + } else if (fxMatch && parseInt(fxMatch[1], 10) < 32) { + // Can't say for sure if it is 1 or 0, due to Fx bug 887703 + dntStatus = 'Unspecified'; + } else if (isIE && platform && anomalousWinVersions.indexOf(platform.toString()) !== -1) { + // default is on, which does not honor the specification + dntStatus = 'Unspecified'; + } else { + // sets dntStatus to Disabled or Enabled based on the value returned by the browser. + // If dntStatus is undefined, it will be set to Unspecified + dntStatus = { '0': 'Disabled', '1': 'Enabled' }[dntStatus] || 'Unspecified'; + } + + return dntStatus === 'Enabled' ? true : false; +} diff --git a/doc/template.html b/doc/template.html index f3edaef72d0537..dc79133e5e7ef9 100644 --- a/doc/template.html +++ b/doc/template.html @@ -45,5 +45,6 @@

Table of Contents

+ diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js index 1745c8fea3df5c..442381b54d7b72 100644 --- a/test/doctool/test-doctool-html.js +++ b/test/doctool/test-doctool-html.js @@ -72,11 +72,18 @@ const testData = [ '

I exist and am being linked to.

' + '' }, + { + file: path.join(common.fixturesDir, 'sample_document.md'), + html: '
  1. fish
  2. fish

  3. Redfish

  4. ' + + '
  5. Bluefish
', + analyticsId: 'UA-67020396-1' + }, ]; testData.forEach((item) => { // Normalize expected data by stripping whitespace const expected = item.html.replace(/\s/g, ''); + const includeAnalytics = typeof item.analyticsId !== 'undefined'; fs.readFile(item.file, 'utf8', common.mustCall((err, input) => { assert.ifError(err); @@ -89,6 +96,7 @@ testData.forEach((item) => { filename: 'foo', template: 'doc/template.html', nodeVersion: process.version, + analytics: item.analyticsId, }, common.mustCall((err, output) => { assert.ifError(err); @@ -96,7 +104,17 @@ testData.forEach((item) => { const actual = output.replace(/\s/g, ''); // Assert that the input stripped of all whitespace contains the // expected list - assert.notEqual(actual.indexOf(expected), -1); + assert.notStrictEqual(actual.indexOf(expected), -1); + + // Testing the insertion of Google Analytics script when + // an analytics id is provided. Should not be present by default + if (includeAnalytics) { + assert.notStrictEqual(actual.indexOf('google-analytics.com'), -1, + 'Google Analytics script was not present'); + } else { + assert.strictEqual(actual.indexOf('google-analytics.com'), -1, + 'Google Analytics script was present'); + } })); })); })); diff --git a/tools/doc/generate.js b/tools/doc/generate.js index 31b23c52a08ba7..b7fcf0d4f90da5 100644 --- a/tools/doc/generate.js +++ b/tools/doc/generate.js @@ -11,16 +11,19 @@ let format = 'json'; let template = null; let inputFile = null; let nodeVersion = null; +let analytics = null; args.forEach(function(arg) { - if (!arg.match(/^--/)) { + if (!arg.startsWith('--')) { inputFile = arg; - } else if (arg.match(/^--format=/)) { + } else if (arg.startsWith('--format=')) { format = arg.replace(/^--format=/, ''); - } else if (arg.match(/^--template=/)) { + } else if (arg.startsWith('--template=')) { template = arg.replace(/^--template=/, ''); - } else if (arg.match(/^--node-version=/)) { + } else if (arg.startsWith('--node-version=')) { nodeVersion = arg.replace(/^--node-version=/, ''); + } else if (arg.startsWith('--analytics=')) { + analytics = arg.replace(/^--analytics=/, ''); } }); @@ -54,6 +57,7 @@ function next(er, input) { filename: inputFile, template: template, nodeVersion: nodeVersion, + analytics: analytics, }, function(er, html) { diff --git a/tools/doc/html.js b/tools/doc/html.js index b3e5f8d708cc14..462073c34a74f5 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -67,6 +67,7 @@ function toHTML(opts, cb) { filename: opts.filename, template: template, nodeVersion: nodeVersion, + analytics: opts.analytics, }, cb); }); } @@ -128,6 +129,13 @@ function render(opts, cb) { gtocData.replace('class="nav-' + id, 'class="nav-' + id + ' active') ); + if (opts.analytics) { + template = template.replace( + '', + analyticsScript(opts.analytics) + ); + } + // content has to be the last thing we do with // the lexed tokens, because it's destructive. const content = marked.parser(lexed); @@ -137,6 +145,23 @@ function render(opts, cb) { }); } +function analyticsScript(analytics) { + return ` + + + `; +} + // handle general body-text replacements // for example, link man page references to the actual page function parseText(lexed) { From 3f6a2dbc2f126409e43ee571e64de972c67d1a36 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 22 Jan 2017 21:26:55 -0800 Subject: [PATCH 136/148] test: enhance test-timers In test-timers, confirm that all input values that should be coerced to 1 ms are not being coerced to a significantly larger value. This eliminates the need for the separate test-regress-GH-897. PR-URL: https://github.com/nodejs/node/pull/10960 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca --- test/parallel/test-timers.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-timers.js b/test/parallel/test-timers.js index 0b379e0eb45ad0..87397735eebff2 100644 --- a/test/parallel/test-timers.js +++ b/test/parallel/test-timers.js @@ -1,6 +1,6 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); var inputs = [ undefined, @@ -18,13 +18,14 @@ var inputs = [ -10, -1, -0.5, + -0.1, -0.0, 0, 0.0, + 0.1, 0.5, 1, 1.0, - 10, 2147483648, // browser behaviour: timeouts > 2^31-1 run on next tick 12345678901234 // ditto ]; @@ -43,10 +44,17 @@ inputs.forEach(function(value, index) { }, value); }); -process.on('exit', function() { - // assert that all timers have run +// All values in inputs array coerce to 1 ms. Therefore, they should all run +// before a timer set here for 2 ms. + +setTimeout(common.mustCall(function() { + // assert that all other timers have run inputs.forEach(function(value, index) { - assert.equal(true, timeouts[index]); - assert.equal(true, intervals[index]); + assert(timeouts[index]); + assert(intervals[index]); }); -}); +}), 2); + +// Test 10 ms timeout separately. +setTimeout(common.mustCall(function() {}), 10); +setInterval(common.mustCall(function() { clearInterval(this); }), 10); From 850f85d96e66c5a44ea388aedb83a1f86dee4821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Sat, 21 Jan 2017 20:01:12 +0100 Subject: [PATCH 137/148] benchmark: add benchmark for object properties Adds a benchmark to compare the speed of property setting/getting in four cases: - Dot notation: `obj.prop = value` - Bracket notation with string: `obj['prop'] = value` - Bracket notation with string variable: `obj[prop] = value` - Bracket notation with Symbol variable: `obj[sym] = value` PR-URL: https://github.com/nodejs/node/pull/10949 Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- benchmark/misc/object-property-bench.js | 81 +++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 benchmark/misc/object-property-bench.js diff --git a/benchmark/misc/object-property-bench.js b/benchmark/misc/object-property-bench.js new file mode 100644 index 00000000000000..8ac7683cd54d7e --- /dev/null +++ b/benchmark/misc/object-property-bench.js @@ -0,0 +1,81 @@ +'use strict'; + +const common = require('../common.js'); + +const bench = common.createBenchmark(main, { + method: ['property', 'string', 'variable', 'symbol'], + millions: [1000] +}); + +function runProperty(n) { + const object = {}; + var i = 0; + bench.start(); + for (; i < n; i++) { + object.p1 = 21; + object.p2 = 21; + object.p1 += object.p2; + } + bench.end(n / 1e6); +} + +function runString(n) { + const object = {}; + var i = 0; + bench.start(); + for (; i < n; i++) { + object['p1'] = 21; + object['p2'] = 21; + object['p1'] += object['p2']; + } + bench.end(n / 1e6); +} + +function runVariable(n) { + const object = {}; + const var1 = 'p1'; + const var2 = 'p2'; + var i = 0; + bench.start(); + for (; i < n; i++) { + object[var1] = 21; + object[var2] = 21; + object[var1] += object[var2]; + } + bench.end(n / 1e6); +} + +function runSymbol(n) { + const object = {}; + const symbol1 = Symbol('p1'); + const symbol2 = Symbol('p2'); + var i = 0; + bench.start(); + for (; i < n; i++) { + object[symbol1] = 21; + object[symbol2] = 21; + object[symbol1] += object[symbol2]; + } + bench.end(n / 1e6); +} + +function main(conf) { + const n = +conf.millions * 1e6; + + switch (conf.method) { + case 'property': + runProperty(n); + break; + case 'string': + runString(n); + break; + case 'variable': + runVariable(n); + break; + case 'symbol': + runSymbol(n); + break; + default: + throw new Error('Unexpected method'); + } +} From 2f4b6bda971749c8b9a2d210eb5b942526560df5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius=20do=20Carmo?= Date: Mon, 23 Jan 2017 14:39:40 -0300 Subject: [PATCH 138/148] test: expand test coverage of fs.js * test reading a file passing a not valid enconding Refs: https://coverage.nodejs.org/coverage-067be658f966dafe/root/internal/fs.js.html PR-URL: https://github.com/nodejs/node/pull/10947 Reviewed-By: James M Snell Reviewed-By: Michael Dawson Reviewed-By: Gibson Fahnestock --- test/parallel/test-fs-read-file-assert-encoding.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 test/parallel/test-fs-read-file-assert-encoding.js diff --git a/test/parallel/test-fs-read-file-assert-encoding.js b/test/parallel/test-fs-read-file-assert-encoding.js new file mode 100644 index 00000000000000..897bcd3bc98795 --- /dev/null +++ b/test/parallel/test-fs-read-file-assert-encoding.js @@ -0,0 +1,13 @@ +'use strict'; +require('../common'); + +const assert = require('assert'); +const fs = require('fs'); + +const encoding = 'foo-8'; +const filename = 'bar.txt'; + +assert.throws( + fs.readFile.bind(fs, filename, { encoding }, () => {}), + new RegExp(`Error: Unknown encoding: ${encoding}$`) +); From 14e57c1102b7d68a25f82654a189901f6e0ed6db Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Fri, 20 Jan 2017 16:16:26 -0500 Subject: [PATCH 139/148] benchmark: add more thorough timers benchmarks Refs: https://github.com/nodejs/node/issues/9493 PR-URL: https://github.com/nodejs/node/pull/10925 Reviewed-By: James M Snell Reviewed-By: Trevor Norris --- benchmark/timers/timers-cancel-pooled.js | 32 ++++++++++++++++++++++ benchmark/timers/timers-cancel-unpooled.js | 26 ++++++++++++++++++ benchmark/timers/timers-insert-pooled.js | 18 ++++++++++++ benchmark/timers/timers-insert-unpooled.js | 27 ++++++++++++++++++ benchmark/timers/timers-timeout-pooled.js | 23 ++++++++++++++++ 5 files changed, 126 insertions(+) create mode 100644 benchmark/timers/timers-cancel-pooled.js create mode 100644 benchmark/timers/timers-cancel-unpooled.js create mode 100644 benchmark/timers/timers-insert-pooled.js create mode 100644 benchmark/timers/timers-insert-unpooled.js create mode 100644 benchmark/timers/timers-timeout-pooled.js diff --git a/benchmark/timers/timers-cancel-pooled.js b/benchmark/timers/timers-cancel-pooled.js new file mode 100644 index 00000000000000..47c9fea2cb5b61 --- /dev/null +++ b/benchmark/timers/timers-cancel-pooled.js @@ -0,0 +1,32 @@ +'use strict'; +var common = require('../common.js'); +var assert = require('assert'); + +var bench = common.createBenchmark(main, { + thousands: [500], +}); + +function main(conf) { + var iterations = +conf.thousands * 1e3; + + var timer = setTimeout(() => {}, 1); + for (var i = 0; i < iterations; i++) { + setTimeout(cb, 1); + } + var next = timer._idlePrev; + clearTimeout(timer); + + bench.start(); + + for (var j = 0; j < iterations; j++) { + timer = next; + next = timer._idlePrev; + clearTimeout(timer); + } + + bench.end(iterations / 1e3); +} + +function cb() { + assert(false, 'Timer should not call callback'); +} diff --git a/benchmark/timers/timers-cancel-unpooled.js b/benchmark/timers/timers-cancel-unpooled.js new file mode 100644 index 00000000000000..a040fad69e1c66 --- /dev/null +++ b/benchmark/timers/timers-cancel-unpooled.js @@ -0,0 +1,26 @@ +'use strict'; +var common = require('../common.js'); +var assert = require('assert'); + +var bench = common.createBenchmark(main, { + thousands: [100], +}); + +function main(conf) { + var iterations = +conf.thousands * 1e3; + + var timersList = []; + for (var i = 0; i < iterations; i++) { + timersList.push(setTimeout(cb, i + 1)); + } + + bench.start(); + for (var j = 0; j < iterations + 1; j++) { + clearTimeout(timersList[j]); + } + bench.end(iterations / 1e3); +} + +function cb() { + assert(false, 'Timer ' + this._idleTimeout + ' should not call callback'); +} diff --git a/benchmark/timers/timers-insert-pooled.js b/benchmark/timers/timers-insert-pooled.js new file mode 100644 index 00000000000000..11c35319b11d69 --- /dev/null +++ b/benchmark/timers/timers-insert-pooled.js @@ -0,0 +1,18 @@ +'use strict'; +var common = require('../common.js'); + +var bench = common.createBenchmark(main, { + thousands: [500], +}); + +function main(conf) { + var iterations = +conf.thousands * 1e3; + + bench.start(); + + for (var i = 0; i < iterations; i++) { + setTimeout(() => {}, 1); + } + + bench.end(iterations / 1e3); +} diff --git a/benchmark/timers/timers-insert-unpooled.js b/benchmark/timers/timers-insert-unpooled.js new file mode 100644 index 00000000000000..91eabeb04e9d4f --- /dev/null +++ b/benchmark/timers/timers-insert-unpooled.js @@ -0,0 +1,27 @@ +'use strict'; +var common = require('../common.js'); +var assert = require('assert'); + +var bench = common.createBenchmark(main, { + thousands: [100], +}); + +function main(conf) { + var iterations = +conf.thousands * 1e3; + + var timersList = []; + + bench.start(); + for (var i = 0; i < iterations; i++) { + timersList.push(setTimeout(cb, i + 1)); + } + bench.end(iterations / 1e3); + + for (var j = 0; j < iterations + 1; j++) { + clearTimeout(timersList[j]); + } +} + +function cb() { + assert(false, 'Timer ' + this._idleTimeout + ' should not call callback'); +} diff --git a/benchmark/timers/timers-timeout-pooled.js b/benchmark/timers/timers-timeout-pooled.js new file mode 100644 index 00000000000000..feaec23237f13d --- /dev/null +++ b/benchmark/timers/timers-timeout-pooled.js @@ -0,0 +1,23 @@ +'use strict'; +var common = require('../common.js'); + +var bench = common.createBenchmark(main, { + thousands: [500], +}); + +function main(conf) { + var iterations = +conf.thousands * 1e3; + var count = 0; + + for (var i = 0; i < iterations; i++) { + setTimeout(cb, 1); + } + + bench.start(); + + function cb() { + count++; + if (count === iterations) + bench.end(iterations / 1e3); + } +} From dc24127e5c67ae7d5e113886d27b00a42f6d8d3c Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 25 Jan 2017 09:15:25 -0800 Subject: [PATCH 140/148] test: allow for slow hosts in spawnSync() test test-child-process-spawnsync-timeout failed from time to time on Raspberry Pi devices. Use common.platformTimeout() to allow a little more time to run on resource-constrained hosts. PR-URL: https://github.com/nodejs/node/pull/10998 Reviewed-By: Colin Ihrig Reviewed-By: Santiago Gimeno Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca --- test/parallel/test-child-process-spawnsync-timeout.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-child-process-spawnsync-timeout.js b/test/parallel/test-child-process-spawnsync-timeout.js index 122a65825949df..c804f7502755bb 100644 --- a/test/parallel/test-child-process-spawnsync-timeout.js +++ b/test/parallel/test-child-process-spawnsync-timeout.js @@ -1,11 +1,11 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); var spawnSync = require('child_process').spawnSync; -var TIMER = 200; -var SLEEP = 5000; +const TIMER = 200; +const SLEEP = common.platformTimeout(5000); switch (process.argv[2]) { case 'child': @@ -19,8 +19,7 @@ switch (process.argv[2]) { var ret = spawnSync(process.execPath, [__filename, 'child'], {timeout: TIMER}); assert.strictEqual(ret.error.errno, 'ETIMEDOUT'); - console.log(ret); - var end = Date.now() - start; + const end = Date.now() - start; assert(end < SLEEP); assert(ret.status > 128 || ret.signal); break; From be34b629decbbd9bb74294361528a996af48d18c Mon Sep 17 00:00:00 2001 From: abouthiroppy Date: Mon, 23 Jan 2017 22:27:00 +0900 Subject: [PATCH 141/148] test: increase coverage for stream's duplex Make use of Arrow function. Add a small test and this file's coverage is 100%. https://github.com/nodejs/node/blob/a647d82f83ad5ddad5db7be2cc24c3d686121792/lib/_stream_duplex.js#L25 Coverage: https://coverage.nodejs.org/coverage-067be658f966dafe/root/_stream_duplex.js.html PR-URL: https://github.com/nodejs/node/pull/10963 Reviewed-By: Colin Ihrig Reviewed-By: Anna Henningsen Reviewed-By: Italo A. Casas Reviewed-By: James M Snell Reviewed-By: Michael Dawson Reviewed-By: Luigi Pinca Reviewed-By: Matteo Collina --- test/parallel/test-stream-duplex.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-stream-duplex.js b/test/parallel/test-stream-duplex.js index 3760960ac9346c..0b71b3d9a50569 100644 --- a/test/parallel/test-stream-duplex.js +++ b/test/parallel/test-stream-duplex.js @@ -5,27 +5,28 @@ const Duplex = require('stream').Transform; const stream = new Duplex({ objectMode: true }); +assert(Duplex() instanceof Duplex); assert(stream._readableState.objectMode); assert(stream._writableState.objectMode); let written; let read; -stream._write = function(obj, _, cb) { +stream._write = (obj, _, cb) => { written = obj; cb(); }; -stream._read = function() {}; +stream._read = () => {}; -stream.on('data', function(obj) { +stream.on('data', (obj) => { read = obj; }); stream.push({ val: 1 }); stream.end({ val: 2 }); -process.on('exit', function() { - assert(read.val === 1); - assert(written.val === 2); +process.on('exit', () => { + assert.strictEqual(read.val, 1); + assert.strictEqual(written.val, 2); }); From fc2bb2c8efb670f82b063d735219a5bb55ea6276 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Thu, 26 Jan 2017 01:58:34 +0100 Subject: [PATCH 142/148] doc: remove Chris Dickinson from active releasers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The last release Chris did was v1.8.1 from April 2015. PR-URL: https://github.com/nodejs/node/pull/11011 Reviewed-By: Colin Ihrig Reviewed-By: Evan Lucas Reviewed-By: James M Snell Reviewed-By: Jeremiah Senkpiel Reviewed-By: Michael Dawson Reviewed-By: Rich Trott Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Сковорода Никита Андреевич --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e5bbf31b7a75ee..43f19ade786830 100644 --- a/README.md +++ b/README.md @@ -352,8 +352,6 @@ project. Node.js releases are signed with one of the following GPG keys: -* **Chris Dickinson** <christopher.s.dickinson@gmail.com> -`9554F04D7259F04124DE6B476D5A82AC7E37093B` * **Colin Ihrig** <cjihrig@gmail.com> `94AE36675C464D64BAFA68DD7434390BDBE9B9C5` * **Evan Lucas** <evanlucas@me.com> @@ -372,7 +370,6 @@ Node.js releases are signed with one of the following GPG keys: The full set of trusted release keys can be imported by running: ```shell -gpg --keyserver pool.sks-keyservers.net --recv-keys 9554F04D7259F04124DE6B476D5A82AC7E37093B gpg --keyserver pool.sks-keyservers.net --recv-keys 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 gpg --keyserver pool.sks-keyservers.net --recv-keys FD3A5288F042B6850C66B31F09FE44734EB7990E gpg --keyserver pool.sks-keyservers.net --recv-keys 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 @@ -387,6 +384,8 @@ on what to do with these keys to verify that a downloaded file is official. Previous releases may also have been signed with one of the following GPG keys: +* **Chris Dickinson** <christopher.s.dickinson@gmail.com> +`9554F04D7259F04124DE6B476D5A82AC7E37093B` * **Isaac Z. Schlueter** <i@izs.me> `93C7E9E91B49E432C2F75674B0A78B0A6C481CF6` * **Julien Gilli** <jgilli@fastmail.fm> From 1df09f9d3780dbdabe40cc530c3dba27cf8fcec0 Mon Sep 17 00:00:00 2001 From: AnnaMag Date: Thu, 26 Jan 2017 17:29:07 +0000 Subject: [PATCH 143/148] test: add known_issues test for #10223 PR-URL: https://github.com/nodejs/node/pull/11024 Reviewed-By: Colin Ihrig Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Anna Henningsen --- .../test-vm-data-property-writable.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 test/known_issues/test-vm-data-property-writable.js diff --git a/test/known_issues/test-vm-data-property-writable.js b/test/known_issues/test-vm-data-property-writable.js new file mode 100644 index 00000000000000..f29052a73a7b6b --- /dev/null +++ b/test/known_issues/test-vm-data-property-writable.js @@ -0,0 +1,17 @@ +'use strict'; +// Refs: https://github.com/nodejs/node/issues/10223 + +require('../common'); +const vm = require('vm'); +const assert = require('assert'); + +const context = vm.createContext({}); + +const code = ` + Object.defineProperty(this, 'foo', {value: 5}); + Object.getOwnPropertyDescriptor(this, 'foo'); +`; + +const desc = vm.runInContext(code, context); + +assert.strictEqual(desc.writable, false); From f854d8c789ddde3c04b1f41fb1c32e159c0e7bb4 Mon Sep 17 00:00:00 2001 From: cjihrig Date: Thu, 9 Feb 2017 20:59:50 -0500 Subject: [PATCH 144/148] test: increase setMulticastLoopback() coverage PR-URL: https://github.com/nodejs/node/pull/11277 Reviewed-By: James M Snell --- .../parallel/test-dgram-multicast-loopback.js | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/test/parallel/test-dgram-multicast-loopback.js b/test/parallel/test-dgram-multicast-loopback.js index 01def7e28160cd..c1eedcd1c98900 100644 --- a/test/parallel/test-dgram-multicast-loopback.js +++ b/test/parallel/test-dgram-multicast-loopback.js @@ -2,11 +2,22 @@ const common = require('../common'); const assert = require('assert'); const dgram = require('dgram'); -const socket = dgram.createSocket('udp4'); - -socket.bind(0); -socket.on('listening', common.mustCall(() => { - const result = socket.setMulticastLoopback(16); - assert.strictEqual(result, 16); - socket.close(); -})); + +{ + const socket = dgram.createSocket('udp4'); + + assert.throws(() => { + socket.setMulticastLoopback(16); + }, /^Error: setMulticastLoopback EBADF$/); +} + +{ + const socket = dgram.createSocket('udp4'); + + socket.bind(0); + socket.on('listening', common.mustCall(() => { + assert.strictEqual(socket.setMulticastLoopback(16), 16); + assert.strictEqual(socket.setMulticastLoopback(0), 0); + socket.close(); + })); +} From 2c84601062d9455217586ae15bd1a21323ac127c Mon Sep 17 00:00:00 2001 From: Bryan English Date: Thu, 8 Sep 2016 13:52:32 -0700 Subject: [PATCH 145/148] util: don't init Debug if it's not needed yet Because any call to util.inspect() with an object results in inspectPromise() being called, Debug was being initialized even when it's not needed. Instead, the initialization is placed after the isPromise check. PR-URL: https://github.com/nodejs/node/pull/8452 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Evan Lucas --- lib/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/util.js b/lib/util.js index 6128c36a988ec1..2417392a2d3fcf 100644 --- a/lib/util.js +++ b/lib/util.js @@ -231,10 +231,10 @@ function ensureDebugIsInitialized() { function inspectPromise(p) { - ensureDebugIsInitialized(); // Only create a mirror if the object is a Promise. if (!binding.isPromise(p)) return null; + ensureDebugIsInitialized(); const mirror = Debug.MakeMirror(p, true); return {status: mirror.status(), value: mirror.promiseValue().value_}; } From f9e121ead847afa085c7b439f8e152f18738be54 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Wed, 8 Feb 2017 16:02:33 +0200 Subject: [PATCH 146/148] dgram: fix possibly deoptimizing use of arguments This commit adds a guard against an out of bounds access of arguments, and replaces another use of arguments with a named function parameter. Refs: https://github.com/nodejs/node/issues/10323 --- lib/dgram.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/dgram.js b/lib/dgram.js index 484689380e26eb..127d4f5dc54973 100644 --- a/lib/dgram.js +++ b/lib/dgram.js @@ -134,7 +134,7 @@ function replaceHandle(self, newHandle) { self._handle = newHandle; } -Socket.prototype.bind = function(port_ /*, address, callback*/) { +Socket.prototype.bind = function(port_, address_ /*, callback*/) { var self = this; let port = port_; @@ -145,7 +145,7 @@ Socket.prototype.bind = function(port_ /*, address, callback*/) { this._bindState = BIND_STATE_BINDING; - if (typeof arguments[arguments.length - 1] === 'function') + if (arguments.length && typeof arguments[arguments.length - 1] === 'function') self.once('listening', arguments[arguments.length - 1]); if (port instanceof UDP) { @@ -162,7 +162,7 @@ Socket.prototype.bind = function(port_ /*, address, callback*/) { exclusive = !!port.exclusive; port = port.port; } else { - address = typeof arguments[1] === 'function' ? '' : arguments[1]; + address = typeof address_ === 'function' ? '' : address_; exclusive = false; } From 48b5097ea8e2b8e3a74f3b34a857d2f0519d0f28 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sun, 15 Jan 2017 14:23:20 +0100 Subject: [PATCH 147/148] http: make request.abort() destroy the socket `request.abort()` did not destroy the socket if it was called before a socket was assigned to the request and the request did not use an `Agent` or a Unix Domain Socket was used. Fixes: https://github.com/nodejs/node/issues/10812 PR-URL: https://github.com/nodejs/node/pull/10818 Reviewed-By: Ben Noordhuis Reviewed-By: Matteo Collina --- lib/_http_client.js | 6 +++- test/parallel/test-http-abort-queued-2.js | 36 +++++++++++++++++++ .../test-http-client-abort-no-agent.js | 19 ++++++++++ .../test-http-client-abort-unix-socket.js | 24 +++++++++++++ 4 files changed, 84 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-http-abort-queued-2.js create mode 100644 test/parallel/test-http-client-abort-no-agent.js create mode 100644 test/parallel/test-http-client-abort-unix-socket.js diff --git a/lib/_http_client.js b/lib/_http_client.js index 26590b9aec2e23..2002d2bc8ea512 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -530,7 +530,11 @@ ClientRequest.prototype.onSocket = function(socket) { function onSocketNT(req, socket) { if (req.aborted) { // If we were aborted while waiting for a socket, skip the whole thing. - socket.emit('free'); + if (req.socketPath || !req.agent) { + socket.destroy(); + } else { + socket.emit('free'); + } } else { tickOnSocket(req, socket); } diff --git a/test/parallel/test-http-abort-queued-2.js b/test/parallel/test-http-abort-queued-2.js new file mode 100644 index 00000000000000..77dc2a535b0e4f --- /dev/null +++ b/test/parallel/test-http-abort-queued-2.js @@ -0,0 +1,36 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); + +let socketsCreated = 0; + +class Agent extends http.Agent { + createConnection(options, oncreate) { + const socket = super.createConnection(options, oncreate); + socketsCreated++; + return socket; + } +} + +const server = http.createServer((req, res) => res.end()); + +server.listen(0, common.mustCall(() => { + const port = server.address().port; + const agent = new Agent({ + keepAlive: true, + maxSockets: 1 + }); + + http.get({agent, port}, (res) => res.resume()); + + const req = http.get({agent, port}, common.fail); + req.abort(); + + http.get({agent, port}, common.mustCall((res) => { + res.resume(); + assert.strictEqual(socketsCreated, 1); + agent.destroy(); + server.close(); + })); +})); diff --git a/test/parallel/test-http-client-abort-no-agent.js b/test/parallel/test-http-client-abort-no-agent.js new file mode 100644 index 00000000000000..875d2ce6469d46 --- /dev/null +++ b/test/parallel/test-http-client-abort-no-agent.js @@ -0,0 +1,19 @@ +'use strict'; +const common = require('../common'); +const http = require('http'); +const net = require('net'); + +const server = http.createServer(common.fail); + +server.listen(0, common.mustCall(() => { + const req = http.get({ + createConnection(options, oncreate) { + const socket = net.createConnection(options, oncreate); + socket.once('close', () => server.close()); + return socket; + }, + port: server.address().port + }); + + req.abort(); +})); diff --git a/test/parallel/test-http-client-abort-unix-socket.js b/test/parallel/test-http-client-abort-unix-socket.js new file mode 100644 index 00000000000000..0b7c5e5ddea6dd --- /dev/null +++ b/test/parallel/test-http-client-abort-unix-socket.js @@ -0,0 +1,24 @@ +'use strict'; +const common = require('../common'); +const http = require('http'); + +const server = http.createServer(common.fail); + +class Agent extends http.Agent { + createConnection(options, oncreate) { + const socket = super.createConnection(options, oncreate); + socket.once('close', () => server.close()); + return socket; + } +} + +common.refreshTmpDir(); + +server.listen(common.PIPE, common.mustCall(() => { + const req = http.get({ + agent: new Agent(), + socketPath: common.PIPE + }); + + req.abort(); +})); From 9551665b5ba6a855f71a43a89fcd0ef997b4038f Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Wed, 8 Mar 2017 17:37:03 -0800 Subject: [PATCH 148/148] 2017-03-21, Version 4.8.1 'Argon' (LTS) Notable Changes: * buffer: - The performance of `.toJSON()` is now up to 2859% faster on average (Brian White) https://github.com/nodejs/node/pull/10895 * IPC: - Batched writes have been enabled for process IPC on platforms that support Unix Domain Sockets. (Alexey Orlenko) https://github.com/nodejs/node/pull/10677 - Performance gains may be up to 40% for some workloads. * http: - Control characters are now always rejected when using `http.request()`. (Ben Noordhuis) https://github.com/nodejs/node/pull/8923 * node: - Heap statistics now support values larger than 4GB. (Ben Noordhuis) https://github.com/nodejs/node/pull/10186 --- CHANGELOG.md | 165 +++++++++++++++++++++++++++++++++++++++++++++ src/node_version.h | 2 +- 2 files changed, 166 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 974cbb51b42d9c..bfd91403b5e4cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,170 @@ # Node.js ChangeLog +## 2017-03-21, Version 4.8.1 'Argon' (LTS), @MylesBorins + +This LTS release comes with 147 commits. This includes 55 which are test related, +41 which are doc related, 11 which are build / tool related, +and 1 commits which are updates to dependencies. + +### Notable Changes + +* **buffer**: The performance of `.toJSON()` is now up to 2859% faster on average. (Brian White) [#10895](https://github.com/nodejs/node/pull/10895) +* **IPC**: Batched writes have been enabled for process IPC on platforms that support Unix Domain Sockets. (Alexey Orlenko) [#10677](https://github.com/nodejs/node/pull/10677) + - Performance gains may be up to 40% for some workloads. +* **http**: + - Control characters are now always rejected when using `http.request()`. (Ben Noordhuis) [#8923](https://github.com/nodejs/node/pull/8923) +* **node**: Heap statistics now support values larger than 4GB. (Ben Noordhuis) [#10186](https://github.com/nodejs/node/pull/10186) + +### Commits + +* [[`77f23ec5af`](https://github.com/nodejs/node/commit/77f23ec5af)] - **assert**: unlock the assert API (Rich Trott) [#11304](https://github.com/nodejs/node/pull/11304) +* [[`090037a41a`](https://github.com/nodejs/node/commit/090037a41a)] - **assert**: remove unneeded condition (Rich Trott) [#11314](https://github.com/nodejs/node/pull/11314) +* [[`75af859af7`](https://github.com/nodejs/node/commit/75af859af7)] - **assert**: apply minor refactoring (Rich Trott) [#11511](https://github.com/nodejs/node/pull/11511) +* [[`994f562858`](https://github.com/nodejs/node/commit/994f562858)] - **assert**: update comments (Kai Cataldo) [#10579](https://github.com/nodejs/node/pull/10579) +* [[`14e57c1102`](https://github.com/nodejs/node/commit/14e57c1102)] - **benchmark**: add more thorough timers benchmarks (Jeremiah Senkpiel) [#10925](https://github.com/nodejs/node/pull/10925) +* [[`850f85d96e`](https://github.com/nodejs/node/commit/850f85d96e)] - **benchmark**: add benchmark for object properties (Michaël Zasso) [#10949](https://github.com/nodejs/node/pull/10949) +* [[`626875f2e4`](https://github.com/nodejs/node/commit/626875f2e4)] - **benchmark**: don't lint autogenerated modules (Brian White) [#10756](https://github.com/nodejs/node/pull/10756) +* [[`9da6ebd73f`](https://github.com/nodejs/node/commit/9da6ebd73f)] - **benchmark**: add dgram bind(+/- params) benchmark (Vse Mozhet Byt) [#11313](https://github.com/nodejs/node/pull/11313) +* [[`a597c11ba4`](https://github.com/nodejs/node/commit/a597c11ba4)] - **benchmark**: improve readability of net benchmarks (Brian White) [#10446](https://github.com/nodejs/node/pull/10446) +* [[`22c25dee92`](https://github.com/nodejs/node/commit/22c25dee92)] - **buffer**: improve toJSON() performance (Brian White) [#10895](https://github.com/nodejs/node/pull/10895) +* [[`af3c21197d`](https://github.com/nodejs/node/commit/af3c21197d)] - **build**: move source files from headers section (Daniel Bevenius) [#10850](https://github.com/nodejs/node/pull/10850) +* [[`4bb61553f0`](https://github.com/nodejs/node/commit/4bb61553f0)] - **build**: disable C4267 conversion compiler warning (Ben Noordhuis) [#11205](https://github.com/nodejs/node/pull/11205) +* [[`6a45ac0ea9`](https://github.com/nodejs/node/commit/6a45ac0ea9)] - **build**: fix newlines in addon build output (Brian White) [#11466](https://github.com/nodejs/node/pull/11466) +* [[`bfc553d55d`](https://github.com/nodejs/node/commit/bfc553d55d)] - **build**: fail on CI if leftover processes (Rich Trott) [#11269](https://github.com/nodejs/node/pull/11269) +* [[`094bfe66aa`](https://github.com/nodejs/node/commit/094bfe66aa)] - **build**: fix node_g target (Daniel Bevenius) [#10153](https://github.com/nodejs/node/pull/10153) +* [[`87db4f7225`](https://github.com/nodejs/node/commit/87db4f7225)] - **build**: Don't regenerate node symlink (sxa555) [#9827](https://github.com/nodejs/node/pull/9827) +* [[`e0dc0ceb37`](https://github.com/nodejs/node/commit/e0dc0ceb37)] - **build**: don't squash signal handlers with --shared (Stewart X Addison) [#10539](https://github.com/nodejs/node/pull/10539) +* [[`4676eec382`](https://github.com/nodejs/node/commit/4676eec382)] - **child_process**: remove empty if condition (cjihrig) [#11427](https://github.com/nodejs/node/pull/11427) +* [[`2b867d2ae5`](https://github.com/nodejs/node/commit/2b867d2ae5)] - **child_process**: refactor internal/child_process.js (Arseniy Maximov) [#11366](https://github.com/nodejs/node/pull/11366) +* [[`c9a92ff494`](https://github.com/nodejs/node/commit/c9a92ff494)] - **crypto**: return the retval of HMAC_Update (Travis Meisenheimer) [#10891](https://github.com/nodejs/node/pull/10891) +* [[`9c53e402d7`](https://github.com/nodejs/node/commit/9c53e402d7)] - **crypto**: freelist_max_len is gone in OpenSSL 1.1.0 (Adam Langley) [#10859](https://github.com/nodejs/node/pull/10859) +* [[`c6f6b029a1`](https://github.com/nodejs/node/commit/c6f6b029a1)] - **crypto**: add cert check issued by StartCom/WoSign (Shigeki Ohtsu) [#9469](https://github.com/nodejs/node/pull/9469) +* [[`c56719f47a`](https://github.com/nodejs/node/commit/c56719f47a)] - **crypto**: Remove expired certs from CNNIC whitelist (Shigeki Ohtsu) [#9469](https://github.com/nodejs/node/pull/9469) +* [[`b48f6ffc63`](https://github.com/nodejs/node/commit/b48f6ffc63)] - **crypto**: use CHECK_NE instead of ABORT or abort (Sam Roberts) [#10413](https://github.com/nodejs/node/pull/10413) +* [[`35a660ee70`](https://github.com/nodejs/node/commit/35a660ee70)] - **crypto**: fix handling of root_cert_store. (Adam Langley) [#9409](https://github.com/nodejs/node/pull/9409) +* [[`3516f35b77`](https://github.com/nodejs/node/commit/3516f35b77)] - **deps**: backport 7c3748a from upstream V8 (Cristian Cavalli) [#10873](https://github.com/nodejs/node/pull/10873) +* [[`f9e121ead8`](https://github.com/nodejs/node/commit/f9e121ead8)] - **dgram**: fix possibly deoptimizing use of arguments (Vse Mozhet Byt) +* [[`fc2bb2c8ef`](https://github.com/nodejs/node/commit/fc2bb2c8ef)] - **doc**: remove Chris Dickinson from active releasers (Ben Noordhuis) [#11011](https://github.com/nodejs/node/pull/11011) +* [[`725a89606b`](https://github.com/nodejs/node/commit/725a89606b)] - **doc**: remove duplicate properties bullet in readme (Javis Sullivan) [#10741](https://github.com/nodejs/node/pull/10741) +* [[`db03294c41`](https://github.com/nodejs/node/commit/db03294c41)] - **doc**: fix typo in http.md (Peter Mescalchin) [#10975](https://github.com/nodejs/node/pull/10975) +* [[`15188900b8`](https://github.com/nodejs/node/commit/15188900b8)] - **doc**: add who to CC list for dgram (cjihrig) [#11035](https://github.com/nodejs/node/pull/11035) +* [[`a0742902bd`](https://github.com/nodejs/node/commit/a0742902bd)] - **doc**: correct and complete dgram's Socket.bind docs (Alex Jordan) [#11025](https://github.com/nodejs/node/pull/11025) +* [[`f464dd837f`](https://github.com/nodejs/node/commit/f464dd837f)] - **doc**: edit CONTRIBUTING.md for clarity (Rich Trott) [#11045](https://github.com/nodejs/node/pull/11045) +* [[`07dfed8f45`](https://github.com/nodejs/node/commit/07dfed8f45)] - **doc**: fix confusing example in dns.md (Vse Mozhet Byt) [#11022](https://github.com/nodejs/node/pull/11022) +* [[`d55d760086`](https://github.com/nodejs/node/commit/d55d760086)] - **doc**: add personal pronouns option (Rich Trott) [#11089](https://github.com/nodejs/node/pull/11089) +* [[`b86843a463`](https://github.com/nodejs/node/commit/b86843a463)] - **doc**: clarify msg when doc/api/cli.md not updated (Stewart X Addison) [#10872](https://github.com/nodejs/node/pull/10872) +* [[`c2d70908e6`](https://github.com/nodejs/node/commit/c2d70908e6)] - **doc**: edit stability text for clarity and style (Rich Trott) [#11112](https://github.com/nodejs/node/pull/11112) +* [[`115448ec94`](https://github.com/nodejs/node/commit/115448ec94)] - **doc**: remove assertions about assert (Rich Trott) [#11113](https://github.com/nodejs/node/pull/11113) +* [[`e90317d739`](https://github.com/nodejs/node/commit/e90317d739)] - **doc**: fix "initial delay" link in http.md (Timo Tijhof) [#11108](https://github.com/nodejs/node/pull/11108) +* [[`788d736ab6`](https://github.com/nodejs/node/commit/788d736ab6)] - **doc**: typographical fixes in COLLABORATOR_GUIDE.md (Anna Henningsen) [#11163](https://github.com/nodejs/node/pull/11163) +* [[`2016aa4e07`](https://github.com/nodejs/node/commit/2016aa4e07)] - **doc**: add not-an-aardvark as ESLint contact (Rich Trott) [#11169](https://github.com/nodejs/node/pull/11169) +* [[`2b6ee39264`](https://github.com/nodejs/node/commit/2b6ee39264)] - **doc**: improve testing guide (Joyee Cheung) [#11150](https://github.com/nodejs/node/pull/11150) +* [[`aae768c599`](https://github.com/nodejs/node/commit/aae768c599)] - **doc**: remove extraneous paragraph from assert doc (Rich Trott) [#11174](https://github.com/nodejs/node/pull/11174) +* [[`ca4b2f6154`](https://github.com/nodejs/node/commit/ca4b2f6154)] - **doc**: fix typo in dgram doc (Rich Trott) [#11186](https://github.com/nodejs/node/pull/11186) +* [[`bb1e97c31a`](https://github.com/nodejs/node/commit/bb1e97c31a)] - **doc**: add and fix System Error properties (Daiki Arai) [#10986](https://github.com/nodejs/node/pull/10986) +* [[`e1e02efac5`](https://github.com/nodejs/node/commit/e1e02efac5)] - **doc**: clarify the behavior of Buffer.byteLength (Nikolai Vavilov) [#11238](https://github.com/nodejs/node/pull/11238) +* [[`30d9202f54`](https://github.com/nodejs/node/commit/30d9202f54)] - **doc**: improve consistency in documentation titles (Vse Mozhet Byt) [#11230](https://github.com/nodejs/node/pull/11230) +* [[`10afa8befc`](https://github.com/nodejs/node/commit/10afa8befc)] - **doc**: drop "and io.js" from release section (Ben Noordhuis) [#11054](https://github.com/nodejs/node/pull/11054) +* [[`6f1db35e27`](https://github.com/nodejs/node/commit/6f1db35e27)] - **doc**: update email and add personal pronoun (JungMinu) [#11318](https://github.com/nodejs/node/pull/11318) +* [[`61ac3346ba`](https://github.com/nodejs/node/commit/61ac3346ba)] - **doc**: update code examples in domain.md (Vse Mozhet Byt) [#11110](https://github.com/nodejs/node/pull/11110) +* [[`0c9ea4fe8b`](https://github.com/nodejs/node/commit/0c9ea4fe8b)] - **doc**: dns examples implied string args were arrays (Sam Roberts) [#11350](https://github.com/nodejs/node/pull/11350) +* [[`485ec6c180`](https://github.com/nodejs/node/commit/485ec6c180)] - **doc**: change STYLE-GUIDE to STYLE_GUIDE (Dean Coakley) [#11460](https://github.com/nodejs/node/pull/11460) +* [[`41bf266b0a`](https://github.com/nodejs/node/commit/41bf266b0a)] - **doc**: add STYLE_GUIDE (moved from nodejs/docs) (Gibson Fahnestock) [#11321](https://github.com/nodejs/node/pull/11321) +* [[`6abfcd560b`](https://github.com/nodejs/node/commit/6abfcd560b)] - **doc**: add comment for net.Server's error event (QianJin2013) [#11136](https://github.com/nodejs/node/pull/11136) +* [[`f4bc12dd11`](https://github.com/nodejs/node/commit/f4bc12dd11)] - **doc**: note message event listeners ref IPC channels (Diego Rodríguez Baquero) [#11494](https://github.com/nodejs/node/pull/11494) +* [[`09c9105a79`](https://github.com/nodejs/node/commit/09c9105a79)] - **doc**: argument types for assert methods (Amelia Clarke) [#11548](https://github.com/nodejs/node/pull/11548) +* [[`d622b67302`](https://github.com/nodejs/node/commit/d622b67302)] - **doc**: document clientRequest.aborted (Zach Bjornson) [#11544](https://github.com/nodejs/node/pull/11544) +* [[`d0dbf12884`](https://github.com/nodejs/node/commit/d0dbf12884)] - **doc**: update TheAlphaNerd to MylesBorins (Myles Borins) [#10586](https://github.com/nodejs/node/pull/10586) +* [[`05273c5a4e`](https://github.com/nodejs/node/commit/05273c5a4e)] - **doc**: update AUTHORS list to fix name (Noah Rose Ledesma) [#10945](https://github.com/nodejs/node/pull/10945) +* [[`79f700c891`](https://github.com/nodejs/node/commit/79f700c891)] - **doc**: add TimothyGu to collaborators (Timothy Gu) [#10954](https://github.com/nodejs/node/pull/10954) +* [[`e656a4244a`](https://github.com/nodejs/node/commit/e656a4244a)] - **doc**: add edsadr to collaborators (Adrian Estrada) [#10883](https://github.com/nodejs/node/pull/10883) +* [[`6d0e1621e5`](https://github.com/nodejs/node/commit/6d0e1621e5)] - **doc**: clarifying variables in fs.write() (Jessica Quynh Tran) [#9792](https://github.com/nodejs/node/pull/9792) +* [[`7287dddd69`](https://github.com/nodejs/node/commit/7287dddd69)] - **doc**: add links for zlib convenience methods (Anna Henningsen) [#10829](https://github.com/nodejs/node/pull/10829) +* [[`b10842ac77`](https://github.com/nodejs/node/commit/b10842ac77)] - **doc**: sort require statements in tests (Sam Roberts) [#10616](https://github.com/nodejs/node/pull/10616) +* [[`8f0e31b2d9`](https://github.com/nodejs/node/commit/8f0e31b2d9)] - **doc**: add test naming information to guide (Rich Trott) [#10584](https://github.com/nodejs/node/pull/10584) +* [[`56b779db93`](https://github.com/nodejs/node/commit/56b779db93)] - **doc**: "s/git apply/git am -3" in V8 guide (Myles Borins) [#10665](https://github.com/nodejs/node/pull/10665) +* [[`3be7a7adb5`](https://github.com/nodejs/node/commit/3be7a7adb5)] - **doc**: update LTS info for current releases (Evan Lucas) [#10720](https://github.com/nodejs/node/pull/10720) +* [[`530adfdb2a`](https://github.com/nodejs/node/commit/530adfdb2a)] - **doc**: improve rinfo object documentation (Matt Crummey) [#10050](https://github.com/nodejs/node/pull/10050) +* [[`48b5097ea8`](https://github.com/nodejs/node/commit/48b5097ea8)] - **http**: make request.abort() destroy the socket (Luigi Pinca) [#10818](https://github.com/nodejs/node/pull/10818) +* [[`15231aa6e5`](https://github.com/nodejs/node/commit/15231aa6e5)] - **http**: reject control characters in http.request() (Ben Noordhuis) [#8923](https://github.com/nodejs/node/pull/8923) +* [[`fc2cd63998`](https://github.com/nodejs/node/commit/fc2cd63998)] - **lib,src**: support values \> 4GB in heap statistics (Ben Noordhuis) [#10186](https://github.com/nodejs/node/pull/10186) +* [[`533d2bf0a9`](https://github.com/nodejs/node/commit/533d2bf0a9)] - **meta**: add explicit deprecation and semver-major policy (James M Snell) [#7964](https://github.com/nodejs/node/pull/7964) +* [[`923309adef`](https://github.com/nodejs/node/commit/923309adef)] - **meta**: remove Chris Dickinson from CTC (Chris Dickinson) [#11267](https://github.com/nodejs/node/pull/11267) +* [[`342c3e2bb4`](https://github.com/nodejs/node/commit/342c3e2bb4)] - **meta**: adding Italo A. Casas PGP Fingerprint (Italo A. Casas) [#11202](https://github.com/nodejs/node/pull/11202) +* [[`434b00be8a`](https://github.com/nodejs/node/commit/434b00be8a)] - **meta**: decharter the http working group (James M Snell) [#10604](https://github.com/nodejs/node/pull/10604) +* [[`a7df345921`](https://github.com/nodejs/node/commit/a7df345921)] - **net**: prefer === to == (Arseniy Maximov) [#11513](https://github.com/nodejs/node/pull/11513) +* [[`396688f075`](https://github.com/nodejs/node/commit/396688f075)] - **readline**: refactor construct Interface (Jackson Tian) [#4740](https://github.com/nodejs/node/pull/4740) +* [[`a40f8429e6`](https://github.com/nodejs/node/commit/a40f8429e6)] - **readline**: update 6 comparions to strict (Umair Ishaq) [#11078](https://github.com/nodejs/node/pull/11078) +* [[`90d8e118fb`](https://github.com/nodejs/node/commit/90d8e118fb)] - **src**: add a missing space in node_os.cc (Alexey Orlenko) [#10931](https://github.com/nodejs/node/pull/10931) +* [[`279cb09cc3`](https://github.com/nodejs/node/commit/279cb09cc3)] - **src**: enable writev for pipe handles on Unix (Alexey Orlenko) [#10677](https://github.com/nodejs/node/pull/10677) +* [[`a557d6ce1d`](https://github.com/nodejs/node/commit/a557d6ce1d)] - **src**: unconsume stream fix in internal http impl (Roee Kasher) [#11015](https://github.com/nodejs/node/pull/11015) +* [[`c4e1af712e`](https://github.com/nodejs/node/commit/c4e1af712e)] - **src**: remove unused typedef (Ben Noordhuis) [#11322](https://github.com/nodejs/node/pull/11322) +* [[`da2adb7133`](https://github.com/nodejs/node/commit/da2adb7133)] - **src**: update http-parser link (Daniel Bevenius) [#11477](https://github.com/nodejs/node/pull/11477) +* [[`2f48001574`](https://github.com/nodejs/node/commit/2f48001574)] - **src**: use ABORT() macro instead of abort() (Evan Lucas) [#9613](https://github.com/nodejs/node/pull/9613) +* [[`a9eb093ce3`](https://github.com/nodejs/node/commit/a9eb093ce3)] - **src**: fix memory leak introduced in 34febfbf4 (Ben Noordhuis) [#9604](https://github.com/nodejs/node/pull/9604) +* [[`f854d8c789`](https://github.com/nodejs/node/commit/f854d8c789)] - **test**: increase setMulticastLoopback() coverage (cjihrig) [#11277](https://github.com/nodejs/node/pull/11277) +* [[`1df09f9d37`](https://github.com/nodejs/node/commit/1df09f9d37)] - **test**: add known_issues test for #10223 (AnnaMag) [#11024](https://github.com/nodejs/node/pull/11024) +* [[`be34b629de`](https://github.com/nodejs/node/commit/be34b629de)] - **test**: increase coverage for stream's duplex (abouthiroppy) [#10963](https://github.com/nodejs/node/pull/10963) +* [[`dc24127e5c`](https://github.com/nodejs/node/commit/dc24127e5c)] - **test**: allow for slow hosts in spawnSync() test (Rich Trott) [#10998](https://github.com/nodejs/node/pull/10998) +* [[`2f4b6bda97`](https://github.com/nodejs/node/commit/2f4b6bda97)] - **test**: expand test coverage of fs.js (Vinícius do Carmo) [#10947](https://github.com/nodejs/node/pull/10947) +* [[`3f6a2dbc2f`](https://github.com/nodejs/node/commit/3f6a2dbc2f)] - **test**: enhance test-timers (Rich Trott) [#10960](https://github.com/nodejs/node/pull/10960) +* [[`6ca9901d8b`](https://github.com/nodejs/node/commit/6ca9901d8b)] - **test**: add process.assert's test (abouthiroppy) [#10911](https://github.com/nodejs/node/pull/10911) +* [[`d8af5a7431`](https://github.com/nodejs/node/commit/d8af5a7431)] - **test**: improve code in test-crypto-verify (Adrian Estrada) [#10845](https://github.com/nodejs/node/pull/10845) +* [[`4d1f7b1df8`](https://github.com/nodejs/node/commit/4d1f7b1df8)] - **test**: add dgram.Socket.prototype.bind's test (abouthiroppy) [#10894](https://github.com/nodejs/node/pull/10894) +* [[`6c1d82c68a`](https://github.com/nodejs/node/commit/6c1d82c68a)] - **test**: improving coverage for dgram (abouthiroppy) [#10783](https://github.com/nodejs/node/pull/10783) +* [[`017afd48fd`](https://github.com/nodejs/node/commit/017afd48fd)] - **test**: improve code in test-console-instance (Adrian Estrada) [#10813](https://github.com/nodejs/node/pull/10813) +* [[`1b1ba741c3`](https://github.com/nodejs/node/commit/1b1ba741c3)] - **test**: improve code in test-domain-multi (Adrian Estrada) [#10798](https://github.com/nodejs/node/pull/10798) +* [[`ee27917a65`](https://github.com/nodejs/node/commit/ee27917a65)] - **test**: improve test-stream2-large-read-stall (stefan judis) [#10725](https://github.com/nodejs/node/pull/10725) +* [[`9ac2316595`](https://github.com/nodejs/node/commit/9ac2316595)] - **test**: improve code in test-http-host-headers (Adrian Estrada) [#10830](https://github.com/nodejs/node/pull/10830) +* [[`a9278a063f`](https://github.com/nodejs/node/commit/a9278a063f)] - **test**: refactor cluster-preload.js (abouthiroppy) [#10701](https://github.com/nodejs/node/pull/10701) +* [[`db60d92e15`](https://github.com/nodejs/node/commit/db60d92e15)] - **test**: test hmac binding robustness (Sam Roberts) [#10923](https://github.com/nodejs/node/pull/10923) +* [[`a1a850f066`](https://github.com/nodejs/node/commit/a1a850f066)] - **test**: don't connect to :: (use localhost instead) (Gibson Fahnestock) +* [[`b3a8e95af3`](https://github.com/nodejs/node/commit/b3a8e95af3)] - **test**: improve test-assert (richnologies) [#10916](https://github.com/nodejs/node/pull/10916) +* [[`56970efe51`](https://github.com/nodejs/node/commit/56970efe51)] - **test**: increase coverage for punycode's decode (abouthiroppy) [#10940](https://github.com/nodejs/node/pull/10940) +* [[`df69c2148a`](https://github.com/nodejs/node/commit/df69c2148a)] - **test**: check fd 0,1,2 are used, not access mode (John Barboza) [#10339](https://github.com/nodejs/node/pull/10339) +* [[`7bceb4fb48`](https://github.com/nodejs/node/commit/7bceb4fb48)] - **test**: add message verification on assert.throws (Travis Meisenheimer) [#10890](https://github.com/nodejs/node/pull/10890) +* [[`1c223ecc70`](https://github.com/nodejs/node/commit/1c223ecc70)] - **test**: add http-common's test (abouthiroppy) [#10832](https://github.com/nodejs/node/pull/10832) +* [[`89e9da6b6d`](https://github.com/nodejs/node/commit/89e9da6b6d)] - **test**: tests for _readableStream.awaitDrain (Mark) [#8914](https://github.com/nodejs/node/pull/8914) +* [[`53b0f413cd`](https://github.com/nodejs/node/commit/53b0f413cd)] - **test**: improve the code in test-process-cpuUsage (Adrian Estrada) [#10714](https://github.com/nodejs/node/pull/10714) +* [[`b3d1700d1f`](https://github.com/nodejs/node/commit/b3d1700d1f)] - **test**: improve tests in pummel/test-exec (Chase Starr) [#10757](https://github.com/nodejs/node/pull/10757) +* [[`6e7dfb1f45`](https://github.com/nodejs/node/commit/6e7dfb1f45)] - **test**: fix temp-dir option in tools/test.py (Gibson Fahnestock) [#10723](https://github.com/nodejs/node/pull/10723) +* [[`9abde3ac6e`](https://github.com/nodejs/node/commit/9abde3ac6e)] - **test**: use realpath for NODE_TEST_DIR in common.js (Gibson Fahnestock) [#10723](https://github.com/nodejs/node/pull/10723) +* [[`f86c64a13a`](https://github.com/nodejs/node/commit/f86c64a13a)] - **test**: refactor the code of test-keep-alive.js (sivaprasanna) [#10684](https://github.com/nodejs/node/pull/10684) +* [[`4d51db87dc`](https://github.com/nodejs/node/commit/4d51db87dc)] - **test**: refactor test-doctool-html.js (abouthiroppy) [#10696](https://github.com/nodejs/node/pull/10696) +* [[`ab65429e44`](https://github.com/nodejs/node/commit/ab65429e44)] - **test**: refactor test-watch-file.js (sivaprasanna) [#10679](https://github.com/nodejs/node/pull/10679) +* [[`4453c0c1dc`](https://github.com/nodejs/node/commit/4453c0c1dc)] - **test**: refactor the code in test-child-process-spawn-loop.js (sivaprasanna) [#10605](https://github.com/nodejs/node/pull/10605) +* [[`42b86ea968`](https://github.com/nodejs/node/commit/42b86ea968)] - **test**: improve test-http-chunked-304 (Adrian Estrada) [#10462](https://github.com/nodejs/node/pull/10462) +* [[`1ae95e64ee`](https://github.com/nodejs/node/commit/1ae95e64ee)] - **test**: improve test-fs-readfile-zero-byte-liar (Adrian Estrada) [#10570](https://github.com/nodejs/node/pull/10570) +* [[`3f3c78d785`](https://github.com/nodejs/node/commit/3f3c78d785)] - **test**: refactor test-fs-utimes (Junshu Okamoto) [#9290](https://github.com/nodejs/node/pull/9290) +* [[`50a868b3f7`](https://github.com/nodejs/node/commit/50a868b3f7)] - **test**: require handler to be run in sigwinch test (Rich Trott) [#11068](https://github.com/nodejs/node/pull/11068) +* [[`c1f45ec2d0`](https://github.com/nodejs/node/commit/c1f45ec2d0)] - **test**: add 2nd argument to throws in test-assert (Marlena Compton) [#11061](https://github.com/nodejs/node/pull/11061) +* [[`f24aa7e071`](https://github.com/nodejs/node/commit/f24aa7e071)] - **test**: improve error messages in test-npm-install (Gonen Dukas) [#11027](https://github.com/nodejs/node/pull/11027) +* [[`1db89d4009`](https://github.com/nodejs/node/commit/1db89d4009)] - **test**: improve coverage on removeListeners functions (matsuda-koushi) [#11140](https://github.com/nodejs/node/pull/11140) +* [[`c532c16e53`](https://github.com/nodejs/node/commit/c532c16e53)] - **test**: increase specificity in dgram test (Rich Trott) [#11187](https://github.com/nodejs/node/pull/11187) +* [[`cb81ae8eea`](https://github.com/nodejs/node/commit/cb81ae8eea)] - **test**: add vm module edge cases (Franziska Hinkelmann) [#11265](https://github.com/nodejs/node/pull/11265) +* [[`8629c956c3`](https://github.com/nodejs/node/commit/8629c956c3)] - **test**: improve punycode test coverage (Sebastian Van Sande) [#11144](https://github.com/nodejs/node/pull/11144) +* [[`caf1ba15f9`](https://github.com/nodejs/node/commit/caf1ba15f9)] - **test**: add coverage for dgram _createSocketHandle() (cjihrig) [#11291](https://github.com/nodejs/node/pull/11291) +* [[`d729e52ef3`](https://github.com/nodejs/node/commit/d729e52ef3)] - **test**: improve crypto coverage (Akito Ito) [#11280](https://github.com/nodejs/node/pull/11280) +* [[`d1a8588cab`](https://github.com/nodejs/node/commit/d1a8588cab)] - **test**: improve message in net-connect-local-error (Rich Trott) [#11393](https://github.com/nodejs/node/pull/11393) +* [[`f2fb4143b4`](https://github.com/nodejs/node/commit/f2fb4143b4)] - **test**: refactor test-dgram-membership (Rich Trott) [#11388](https://github.com/nodejs/node/pull/11388) +* [[`bf4703d66f`](https://github.com/nodejs/node/commit/bf4703d66f)] - **test**: remove unused args and comparison fix (Alexander) [#11396](https://github.com/nodejs/node/pull/11396) +* [[`28471c23ff`](https://github.com/nodejs/node/commit/28471c23ff)] - **test**: refactor test-http-response-splitting (Arseniy Maximov) [#11429](https://github.com/nodejs/node/pull/11429) +* [[`cd3e17e248`](https://github.com/nodejs/node/commit/cd3e17e248)] - **test**: improve coverage in test-crypto.dh (Eric Christie) [#11253](https://github.com/nodejs/node/pull/11253) +* [[`fa681ea55a`](https://github.com/nodejs/node/commit/fa681ea55a)] - **test**: add regex check to test-module-loading (Tarang Hirani) [#11413](https://github.com/nodejs/node/pull/11413) +* [[`f0eee61a93`](https://github.com/nodejs/node/commit/f0eee61a93)] - **test**: throw check in test-zlib-write-after-close (Jason Wilson) [#11482](https://github.com/nodejs/node/pull/11482) +* [[`f0c7c7fad4`](https://github.com/nodejs/node/commit/f0c7c7fad4)] - **test**: fix flaky test-vm-timeout-rethrow (Kunal Pathak) [#11530](https://github.com/nodejs/node/pull/11530) +* [[`53f2848dc8`](https://github.com/nodejs/node/commit/53f2848dc8)] - **test**: favor assertions over console logging (Rich Trott) [#11547](https://github.com/nodejs/node/pull/11547) +* [[`0109321fd8`](https://github.com/nodejs/node/commit/0109321fd8)] - **test**: refactor test-https-truncate (Rich Trott) [#10225](https://github.com/nodejs/node/pull/10225) +* [[`536733697c`](https://github.com/nodejs/node/commit/536733697c)] - **test**: simplify test-http-client-unescaped-path (Rod Vagg) [#9649](https://github.com/nodejs/node/pull/9649) +* [[`4ce9bfb4e7`](https://github.com/nodejs/node/commit/4ce9bfb4e7)] - **test**: exclude pseudo-tty test pertinent to #11541 (Gireesh Punathil) [#11602](https://github.com/nodejs/node/pull/11602) +* [[`53dd1a8539`](https://github.com/nodejs/node/commit/53dd1a8539)] - **tls**: do not crash on STARTTLS when OCSP requested (Fedor Indutny) [#10706](https://github.com/nodejs/node/pull/10706) +* [[`e607ff52fa`](https://github.com/nodejs/node/commit/e607ff52fa)] - **tools**: rename eslintrc to an undeprecated format (Sakthipriyan Vairamani) [#7699](https://github.com/nodejs/node/pull/7699) +* [[`6648b729b7`](https://github.com/nodejs/node/commit/6648b729b7)] - **tools**: add compile_commands.json gyp generator (Ben Noordhuis) [#7986](https://github.com/nodejs/node/pull/7986) +* [[`8f49962f47`](https://github.com/nodejs/node/commit/8f49962f47)] - **tools**: suggest python2 command in configure (Roman Reiss) [#11375](https://github.com/nodejs/node/pull/11375) +* [[`4b83a83c06`](https://github.com/nodejs/node/commit/4b83a83c06)] - **tools,doc**: add Google Analytics tracking. (Phillip Johnsen) [#6601](https://github.com/nodejs/node/pull/6601) +* [[`ef63af6006`](https://github.com/nodejs/node/commit/ef63af6006)] - **tty**: avoid oob warning in TTYWrap::GetWindowSize() (Dmitry Tsvettsikh) [#11454](https://github.com/nodejs/node/pull/11454) +* [[`2c84601062`](https://github.com/nodejs/node/commit/2c84601062)] - **util**: don't init Debug if it's not needed yet (Bryan English) [#8452](https://github.com/nodejs/node/pull/8452) + ## 2017-02-21, Version 4.8.0 'Argon' (LTS), @MylesBorins This LTS release comes with 118 commits. This includes 73 which are doc diff --git a/src/node_version.h b/src/node_version.h index fb497ea355fab0..abd1236a613feb 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -8,7 +8,7 @@ #define NODE_VERSION_IS_LTS 1 #define NODE_VERSION_LTS_CODENAME "Argon" -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)