From 50e5eff12ab33f868067fb41601e9d8feb2d8177 Mon Sep 17 00:00:00 2001 From: Vse Mozhet Byt Date: Sun, 25 Mar 2018 18:47:22 +0300 Subject: [PATCH 01/10] tools: fix nits in tools/doc/common.js PR-URL: https://github.com/nodejs/node/pull/19599 Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca --- tools/doc/common.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/tools/doc/common.js b/tools/doc/common.js index 3a66cbd7b05..48ff3d1b828 100644 --- a/tools/doc/common.js +++ b/tools/doc/common.js @@ -3,11 +3,9 @@ const yaml = require('js-yaml'); function isYAMLBlock(text) { - return !!text.match(/^\n` + - `${inc}\n\n`; - input = input.split(`${include}\n`).join(`${includeData[fname]}\n`); - if (incCount === 0) { - return cb(null, input); - } - }); + incCount--; + + // Add comments to let the HTML generator know + // how the anchors for headings should look like. + inc = `\n` + + `${inc}\n\n`; + input = input.split(`${include}\n`).join(`${inc}\n`); + + if (incCount === 0) + return cb(null, input.replace(commentExpr, '')); }); }); } From d49661bb80dd6d9c012dc718bcec45c89fe2e3e1 Mon Sep 17 00:00:00 2001 From: Dan Kaplun Date: Sun, 18 Mar 2018 00:36:53 -0400 Subject: [PATCH 03/10] console: don't swallow call stack exceeded errors Fixes test/parallel/test-console-no-swallow-stack-exceeded.js PR-URL: https://github.com/nodejs/node/pull/19423 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig --- lib/console.js | 17 +++++--------- lib/internal/errors.js | 22 +++++++++++++++++++ .../test-console-no-swallow-stack-overflow.js | 18 +++++++++++++++ 3 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 test/parallel/test-console-no-swallow-stack-overflow.js diff --git a/lib/console.js b/lib/console.js index b77832b9876..d70a6b30b72 100644 --- a/lib/console.js +++ b/lib/console.js @@ -21,15 +21,16 @@ 'use strict'; -const { ERR_CONSOLE_WRITABLE_STREAM } = require('internal/errors').codes; +const { + isStackOverflowError, + codes: { ERR_CONSOLE_WRITABLE_STREAM }, +} = require('internal/errors'); const util = require('util'); const kCounts = Symbol('counts'); // Track amount of indentation required via `console.group()`. const kGroupIndent = Symbol('groupIndent'); -let MAX_STACK_MESSAGE; - function Console(stdout, stderr, ignoreErrors = true) { if (!(this instanceof Console)) { return new Console(stdout, stderr, ignoreErrors); @@ -113,17 +114,9 @@ function write(ignoreErrors, stream, string, errorhandler, groupIndent) { stream.write(string, errorhandler); } catch (e) { - if (MAX_STACK_MESSAGE === undefined) { - try { - // eslint-disable-next-line no-unused-vars - function a() { a(); } - } catch (err) { - MAX_STACK_MESSAGE = err.message; - } - } // console is a debugging utility, so it swallowing errors is not desirable // even in edge cases such as low stack space. - if (e.message === MAX_STACK_MESSAGE && e.name === 'RangeError') + if (isStackOverflowError(e)) throw e; // Sorry, there's no proper way to pass along the error here. } finally { diff --git a/lib/internal/errors.js b/lib/internal/errors.js index a8c4bfb3c33..16b4cd2416f 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -569,11 +569,33 @@ function dnsException(err, syscall, hostname) { return ex; } +let MAX_STACK_MESSAGE; +/** + * Returns true if `err` is a `RangeError` with an engine-specific message. + * "Maximum call stack size exceeded" in V8. + * + * @param {Error} err + * @returns {boolean} + */ +function isStackOverflowError(err) { + if (MAX_STACK_MESSAGE === undefined) { + try { + function overflowStack() { overflowStack(); } + overflowStack(); + } catch (err) { + MAX_STACK_MESSAGE = err.message; + } + } + + return err.name === 'RangeError' && err.message === MAX_STACK_MESSAGE; +} + module.exports = exports = { dnsException, errnoException, exceptionWithHostPort, uvException, + isStackOverflowError, message, AssertionError, SystemError, diff --git a/test/parallel/test-console-no-swallow-stack-overflow.js b/test/parallel/test-console-no-swallow-stack-overflow.js new file mode 100644 index 00000000000..f36ba4857e3 --- /dev/null +++ b/test/parallel/test-console-no-swallow-stack-overflow.js @@ -0,0 +1,18 @@ +'use strict'; +const common = require('../common'); +const { Console } = require('console'); +const { Writable } = require('stream'); + +for (const method of ['dir', 'log', 'warn']) { + common.expectsError(() => { + const out = new Writable({ + write: common.mustCall(function write(...args) { + // Exceeds call stack. + return write(...args); + }), + }); + const c = new Console(out, out, true); + + c[method]('Hello, world!'); + }, { name: 'RangeError' }); +} From 0d5720bf039007c96b7bad51cd7a22335a5b5c41 Mon Sep 17 00:00:00 2001 From: Ayush Gupta Date: Tue, 13 Mar 2018 20:42:40 +0530 Subject: [PATCH 04/10] doc: document `make docopen` Documented `make docopen` as a way to read documentation in the browser. PR-URL: https://github.com/nodejs/node/pull/19321 Reviewed-By: Anna Henningsen Reviewed-By: Vse Mozhet Byt Reviewed-By: Luigi Pinca Reviewed-By: Yuta Hiroto Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- BUILDING.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/BUILDING.md b/BUILDING.md index 697d4bd63aa..e3bd7a7e9db 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -206,6 +206,15 @@ To read the documentation: $ man doc/node.1 ``` +If you prefer to read the documentation in a browser, +run the following after `make doc` is finished: + +```console +$ make docopen +``` + +This will open a browser with the documentation. + To test if Node.js was built correctly: ```console From ebbf3936001969905ce28dc588b2c71c3b65c146 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 23 Mar 2018 09:38:16 +0100 Subject: [PATCH 05/10] src: name all builtin init functions Initialize This commit renames a few of the builtin modules init functions to Initialize for consistency. PR-URL: https://github.com/nodejs/node/pull/19550 Reviewed-By: Anna Henningsen Reviewed-By: Tiancheng "Timothy" Gu Reviewed-By: James M Snell --- src/inspector_js_api.cc | 6 +++--- src/node.cc | 4 ++-- src/node_config.cc | 4 ++-- src/node_contextify.cc | 8 ++++---- src/node_crypto.cc | 4 ++-- src/node_file.cc | 10 +++++----- src/node_http_parser.cc | 10 +++++----- src/node_i18n.cc | 10 +++++----- src/node_perf.cc | 8 ++++---- src/node_serdes.cc | 8 ++++---- src/node_trace_events.cc | 10 +++++----- src/node_url.cc | 10 +++++----- src/node_v8.cc | 8 ++++---- src/node_zlib.cc | 10 +++++----- src/uv.cc | 8 ++++---- 15 files changed, 59 insertions(+), 59 deletions(-) diff --git a/src/inspector_js_api.cc b/src/inspector_js_api.cc index 3d806d71ef9..9a380bb2df2 100644 --- a/src/inspector_js_api.cc +++ b/src/inspector_js_api.cc @@ -296,8 +296,8 @@ void Url(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(OneByteString(env->isolate(), url.c_str())); } -void InitInspectorBindings(Local target, Local unused, - Local context, void* priv) { +void Initialize(Local target, Local unused, + Local context, void* priv) { Environment* env = Environment::GetCurrent(context); { auto obj = Object::New(env->isolate()); @@ -341,4 +341,4 @@ void InitInspectorBindings(Local target, Local unused, } // namespace node NODE_BUILTIN_MODULE_CONTEXT_AWARE(inspector, - node::inspector::InitInspectorBindings); + node::inspector::Initialize); diff --git a/src/node.cc b/src/node.cc index 8dfefcae6ec..c0ae99f423f 100644 --- a/src/node.cc +++ b/src/node.cc @@ -4647,7 +4647,7 @@ void RegisterBuiltinModules() { } // namespace node #if !HAVE_INSPECTOR -void InitEmptyBindings() {} +void Initialize() {} -NODE_BUILTIN_MODULE_CONTEXT_AWARE(inspector, InitEmptyBindings) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(inspector, Initialize) #endif // !HAVE_INSPECTOR diff --git a/src/node_config.cc b/src/node_config.cc index cac551ad2c4..0542bff1d65 100644 --- a/src/node_config.cc +++ b/src/node_config.cc @@ -36,7 +36,7 @@ using v8::Value; value, ReadOnly).FromJust(); \ } while (0) -static void InitConfig(Local target, +static void Initialize(Local target, Local unused, Local context) { Environment* env = Environment::GetCurrent(context); @@ -138,4 +138,4 @@ static void InitConfig(Local target, } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(config, node::InitConfig) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(config, node::Initialize) diff --git a/src/node_contextify.cc b/src/node_contextify.cc index 07aa656b2c1..42f66885bb8 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -1143,9 +1143,9 @@ class ContextifyScript : public BaseObject { }; -void InitContextify(Local target, - Local unused, - Local context) { +void Initialize(Local target, + Local unused, + Local context) { Environment* env = Environment::GetCurrent(context); ContextifyContext::Init(env, target); ContextifyScript::Init(env, target); @@ -1154,4 +1154,4 @@ void InitContextify(Local target, } // namespace contextify } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(contextify, node::contextify::InitContextify) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(contextify, node::contextify::Initialize) diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 3253b701f3b..2384f6997c5 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -5778,7 +5778,7 @@ void SetFipsCrypto(const FunctionCallbackInfo& args) { } #endif /* NODE_FIPS_MODE */ -void InitCrypto(Local target, +void Initialize(Local target, Local unused, Local context, void* priv) { @@ -5852,4 +5852,4 @@ void InitCrypto(Local target, } // namespace crypto } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(crypto, node::crypto::InitCrypto) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(crypto, node::crypto::Initialize) diff --git a/src/node_file.cc b/src/node_file.cc index 7b493de131f..533ed6c19cd 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -1857,10 +1857,10 @@ static void Mkdtemp(const FunctionCallbackInfo& args) { } } -void InitFs(Local target, - Local unused, - Local context, - void* priv) { +void Initialize(Local target, + Local unused, + Local context, + void* priv) { Environment* env = Environment::GetCurrent(context); env->SetMethod(target, "access", Access); @@ -1976,4 +1976,4 @@ void InitFs(Local target, } // end namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(fs, node::fs::InitFs) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(fs, node::fs::Initialize) diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 8ab13e07340..7fddb747cd8 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -728,10 +728,10 @@ const struct http_parser_settings Parser::settings = { }; -void InitHttpParser(Local target, - Local unused, - Local context, - void* priv) { +void Initialize(Local target, + Local unused, + Local context, + void* priv) { Environment* env = Environment::GetCurrent(context); Local t = env->NewFunctionTemplate(Parser::New); t->InstanceTemplate()->SetInternalFieldCount(1); @@ -778,4 +778,4 @@ void InitHttpParser(Local target, } // anonymous namespace } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(http_parser, node::InitHttpParser) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(http_parser, node::Initialize) diff --git a/src/node_i18n.cc b/src/node_i18n.cc index d65fc55ed1f..7f462d5aead 100644 --- a/src/node_i18n.cc +++ b/src/node_i18n.cc @@ -852,10 +852,10 @@ static void GetStringWidth(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(width); } -void Init(Local target, - Local unused, - Local context, - void* priv) { +void Initialize(Local target, + Local unused, + Local context, + void* priv) { Environment* env = Environment::GetCurrent(context); env->SetMethod(target, "toUnicode", ToUnicode); env->SetMethod(target, "toASCII", ToASCII); @@ -875,6 +875,6 @@ void Init(Local target, } // namespace i18n } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(icu, node::i18n::Init) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(icu, node::i18n::Initialize) #endif // NODE_HAVE_I18N_SUPPORT diff --git a/src/node_perf.cc b/src/node_perf.cc index 60ab530420e..ac17e5b873b 100644 --- a/src/node_perf.cc +++ b/src/node_perf.cc @@ -372,9 +372,9 @@ void Timerify(const FunctionCallbackInfo& args) { } -void Init(Local target, - Local unused, - Local context) { +void Initialize(Local target, + Local unused, + Local context) { Environment* env = Environment::GetCurrent(context); Isolate* isolate = env->isolate(); performance_state* state = env->performance_state(); @@ -443,4 +443,4 @@ void Init(Local target, } // namespace performance } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(performance, node::performance::Init) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(performance, node::performance::Initialize) diff --git a/src/node_serdes.cc b/src/node_serdes.cc index 5eb4455a0eb..1995eb1b9b5 100644 --- a/src/node_serdes.cc +++ b/src/node_serdes.cc @@ -424,9 +424,9 @@ void DeserializerContext::ReadRawBytes( args.GetReturnValue().Set(offset); } -void InitializeSerdesBindings(Local target, - Local unused, - Local context) { +void Initialize(Local target, + Local unused, + Local context) { Environment* env = Environment::GetCurrent(context); Local ser = env->NewFunctionTemplate(SerializerContext::New); @@ -483,4 +483,4 @@ void InitializeSerdesBindings(Local target, } // anonymous namespace } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(serdes, node::InitializeSerdesBindings) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(serdes, node::Initialize) diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc index f269b32fbef..96d00115fee 100644 --- a/src/node_trace_events.cc +++ b/src/node_trace_events.cc @@ -132,10 +132,10 @@ static void CategoryGroupEnabled(const FunctionCallbackInfo& args) { args.GetReturnValue().Set(*category_group_enabled > 0); } -void InitializeTraceEvents(Local target, - Local unused, - Local context, - void* priv) { +void Initialize(Local target, + Local unused, + Local context, + void* priv) { Environment* env = Environment::GetCurrent(context); env->SetMethod(target, "emit", Emit); @@ -144,4 +144,4 @@ void InitializeTraceEvents(Local target, } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(trace_events, node::InitializeTraceEvents) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(trace_events, node::Initialize) diff --git a/src/node_url.cc b/src/node_url.cc index 6b56628d753..901fa0761a4 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -2290,10 +2290,10 @@ static void SetURLConstructor(const FunctionCallbackInfo& args) { env->set_url_constructor_function(args[0].As()); } -static void Init(Local target, - Local unused, - Local context, - void* priv) { +static void Initialize(Local target, + Local unused, + Local context, + void* priv) { Environment* env = Environment::GetCurrent(context); env->SetMethod(target, "parse", Parse); env->SetMethod(target, "encodeAuth", EncodeAuthSet); @@ -2313,4 +2313,4 @@ static void Init(Local target, } // namespace url } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(url, node::url::Init) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(url, node::url::Initialize) diff --git a/src/node_v8.cc b/src/node_v8.cc index d1514cb0973..bb41b569e6f 100644 --- a/src/node_v8.cc +++ b/src/node_v8.cc @@ -119,9 +119,9 @@ void SetFlagsFromString(const FunctionCallbackInfo& args) { } -void InitializeV8Bindings(Local target, - Local unused, - Local context) { +void Initialize(Local target, + Local unused, + Local context) { Environment* env = Environment::GetCurrent(context); env->SetMethod(target, "cachedDataVersionTag", CachedDataVersionTag); @@ -201,4 +201,4 @@ void InitializeV8Bindings(Local target, } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(v8, node::InitializeV8Bindings) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(v8, node::Initialize) diff --git a/src/node_zlib.cc b/src/node_zlib.cc index 388630d507a..500a62a52bf 100644 --- a/src/node_zlib.cc +++ b/src/node_zlib.cc @@ -681,10 +681,10 @@ class ZCtx : public AsyncWrap { }; -void InitZlib(Local target, - Local unused, - Local context, - void* priv) { +void Initialize(Local target, + Local unused, + Local context, + void* priv) { Environment* env = Environment::GetCurrent(context); Local z = env->NewFunctionTemplate(ZCtx::New); @@ -709,4 +709,4 @@ void InitZlib(Local target, } // anonymous namespace } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(zlib, node::InitZlib) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(zlib, node::Initialize) diff --git a/src/uv.cc b/src/uv.cc index 1ffd093c6ba..85cb2ad5373 100644 --- a/src/uv.cc +++ b/src/uv.cc @@ -50,9 +50,9 @@ void ErrName(const FunctionCallbackInfo& args) { } -void InitializeUV(Local target, - Local unused, - Local context) { +void Initialize(Local target, + Local unused, + Local context) { Environment* env = Environment::GetCurrent(context); Isolate* isolate = env->isolate(); target->Set(FIXED_ONE_BYTE_STRING(isolate, "errname"), @@ -82,4 +82,4 @@ void InitializeUV(Local target, } // anonymous namespace } // namespace node -NODE_BUILTIN_MODULE_CONTEXT_AWARE(uv, node::InitializeUV) +NODE_BUILTIN_MODULE_CONTEXT_AWARE(uv, node::Initialize) From 8fb4ea9f75c8c82c46286bd5ca0c1115c4a5e956 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Tue, 20 Mar 2018 12:39:46 +0100 Subject: [PATCH 06/10] test: add deprecation code to expectWarning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit adds a deprecation code to expectWarning and updates the function to check the passed code against the code property on the warning object. Not all warnings have a deprecation code so for those that don't an explicit code of common.noWarnCode is required. Passing this skips the assertion of the code. PR-URL: https://github.com/nodejs/node/pull/19474 Reviewed-By: Michaël Zasso Reviewed-By: James M Snell Reviewed-By: Tobias Nießen --- test/common/README.md | 10 ++++- test/common/index.js | 39 ++++++++++++++----- test/parallel/test-assert-fail-deprecation.js | 3 +- .../test-buffer-pending-deprecation.js | 2 +- .../parallel/test-child-process-custom-fds.js | 2 +- test/parallel/test-crypto-authenticated.js | 11 ++++-- test/parallel/test-crypto-cipher-decipher.js | 3 +- test/parallel/test-crypto-deprecated.js | 10 +++-- test/parallel/test-fs-filehandle.js | 3 +- test/parallel/test-fs-truncate-fd.js | 2 +- test/parallel/test-fs-truncate.js | 4 +- test/parallel/test-net-server-connections.js | 2 +- test/parallel/test-performance-warning.js | 6 +-- test/parallel/test-process-assert.js | 3 +- .../test-process-emit-warning-from-native.js | 3 +- test/parallel/test-process-env-deprecation.js | 3 +- ...est-promises-unhandled-proxy-rejections.js | 8 ++-- ...st-promises-unhandled-symbol-rejections.js | 10 ++--- test/parallel/test-repl-deprecations.js | 2 +- test/parallel/test-repl-memory-deprecation.js | 2 +- .../test-repl-turn-off-editor-mode.js | 2 +- .../parallel/test-require-deps-deprecation.js | 4 +- test/parallel/test-tls-dhe.js | 3 +- test/parallel/test-tls-ecdh-disable.js | 3 +- test/parallel/test-tls-legacy-deprecated.js | 3 +- test/parallel/test-tls-parse-cert-string.js | 3 +- test/parallel/test-util-inspect-deprecated.js | 3 +- test/parallel/test-util.js | 8 ++-- test/parallel/test-warn-sigprof.js | 3 +- 29 files changed, 101 insertions(+), 59 deletions(-) diff --git a/test/common/README.md b/test/common/README.md index 24468bdfd77..765ebe01231 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -108,11 +108,17 @@ Indicates if there is more than 1gb of total memory. returned function has not been called exactly `exact` number of times when the test is complete, then the test will fail. -### expectWarning(name, expected) +### expectWarning(name, expected, code) * `name` [<string>] * `expected` [<string>] | [<Array>] +* `code` [<string>] -Tests whether `name` and `expected` are part of a raised warning. +Tests whether `name`, `expected`, and `code` are part of a raised warning. If +an expected warning does not have a code then `common.noWarnCode` can be used +to indicate this. + +### noWarnCode +See `common.expectWarning()` for usage. ### fileExists(pathname) * pathname [<string>] diff --git a/test/common/index.js b/test/common/index.js index ff1dc0ce261..f13e61df8c8 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -611,20 +611,32 @@ exports.isAlive = function isAlive(pid) { } }; -function expectWarning(name, expectedMessages) { +exports.noWarnCode = 'no_expected_warning_code'; + +function expectWarning(name, expected) { + const map = new Map(expected); return exports.mustCall((warning) => { assert.strictEqual(warning.name, name); - assert.ok(expectedMessages.includes(warning.message), + assert.ok(map.has(warning.message), `unexpected error message: "${warning.message}"`); + const code = map.get(warning.message); + if (code === undefined) { + throw new Error('An error code must be specified or use ' + + 'common.noWarnCode if there is no error code. The error ' + + `code for this warning was ${warning.code}`); + } + if (code !== exports.noWarnCode) { + assert.strictEqual(warning.code, code); + } // Remove a warning message after it is seen so that we guarantee that we // get each message only once. - expectedMessages.splice(expectedMessages.indexOf(warning.message), 1); - }, expectedMessages.length); + map.delete(expected); + }, map.size); } -function expectWarningByName(name, expected) { +function expectWarningByName(name, expected, code) { if (typeof expected === 'string') { - expected = [expected]; + expected = [[expected, code]]; } process.on('warning', expectWarning(name, expected)); } @@ -633,8 +645,15 @@ function expectWarningByMap(warningMap) { const catchWarning = {}; Object.keys(warningMap).forEach((name) => { let expected = warningMap[name]; - if (typeof expected === 'string') { - expected = [expected]; + if (!Array.isArray(expected)) { + throw new Error('warningMap entries must be arrays consisting of two ' + + 'entries: [message, warningCode]'); + } + if (!(Array.isArray(expected[0]))) { + if (expected.length === 0) { + return; + } + expected = [[expected[0], expected[1]]]; } catchWarning[name] = expectWarning(name, expected); }); @@ -644,9 +663,9 @@ function expectWarningByMap(warningMap) { // accepts a warning name and description or array of descriptions or a map // of warning names to description(s) // ensures a warning is generated for each name/description pair -exports.expectWarning = function(nameOrMap, expected) { +exports.expectWarning = function(nameOrMap, expected, code) { if (typeof nameOrMap === 'string') { - expectWarningByName(nameOrMap, expected); + expectWarningByName(nameOrMap, expected, code); } else { expectWarningByMap(nameOrMap); } diff --git a/test/parallel/test-assert-fail-deprecation.js b/test/parallel/test-assert-fail-deprecation.js index aab26d42725..68ebcd612d3 100644 --- a/test/parallel/test-assert-fail-deprecation.js +++ b/test/parallel/test-assert-fail-deprecation.js @@ -6,7 +6,8 @@ const assert = require('assert'); common.expectWarning( 'DeprecationWarning', 'assert.fail() with more than one argument is deprecated. ' + - 'Please use assert.strictEqual() instead or only pass a message.' + 'Please use assert.strictEqual() instead or only pass a message.', + 'DEP0094' ); // Two args only, operator defaults to '!=' diff --git a/test/parallel/test-buffer-pending-deprecation.js b/test/parallel/test-buffer-pending-deprecation.js index 060eae2a516..15b5a5140e1 100644 --- a/test/parallel/test-buffer-pending-deprecation.js +++ b/test/parallel/test-buffer-pending-deprecation.js @@ -9,7 +9,7 @@ const bufferWarning = 'The Buffer() and new Buffer() constructors are not ' + 'Buffer.allocUnsafe(), or Buffer.from() construction ' + 'methods instead.'; -common.expectWarning('DeprecationWarning', bufferWarning); +common.expectWarning('DeprecationWarning', bufferWarning, 'DEP0005'); // This is used to make sure that a warning is only emitted once even though // `new Buffer()` is called twice. diff --git a/test/parallel/test-child-process-custom-fds.js b/test/parallel/test-child-process-custom-fds.js index 910babdd6fb..fbfc8776a37 100644 --- a/test/parallel/test-child-process-custom-fds.js +++ b/test/parallel/test-child-process-custom-fds.js @@ -9,7 +9,7 @@ const oldSpawnSync = internalCp.spawnSync; { const msg = 'child_process: options.customFds option is deprecated. ' + 'Use options.stdio instead.'; - common.expectWarning('DeprecationWarning', msg); + common.expectWarning('DeprecationWarning', msg, 'DEP0006'); const customFds = [-1, process.stdout.fd, process.stderr.fd]; internalCp.spawnSync = common.mustCall(function(opts) { diff --git a/test/parallel/test-crypto-authenticated.js b/test/parallel/test-crypto-authenticated.js index c016b3500de..9979a1b861d 100644 --- a/test/parallel/test-crypto-authenticated.js +++ b/test/parallel/test-crypto-authenticated.js @@ -336,13 +336,16 @@ const errMessages = { const ciphers = crypto.getCiphers(); const expectedWarnings = common.hasFipsCrypto ? - [] : ['Use Cipheriv for counter mode of aes-192-gcm']; + [] : [['Use Cipheriv for counter mode of aes-192-gcm', + common.noWarnCode]]; const expectedDeprecationWarnings = [0, 1, 2, 6, 9, 10, 11, 17] - .map((i) => `Permitting authentication tag lengths of ${i} bytes is ` + - 'deprecated. Valid GCM tag lengths are 4, 8, 12, 13, 14, 15, 16.'); + .map((i) => [`Permitting authentication tag lengths of ${i} bytes is ` + + 'deprecated. Valid GCM tag lengths are 4, 8, 12, 13, 14, 15, 16.', + 'DEP0090']); -expectedDeprecationWarnings.push('crypto.DEFAULT_ENCODING is deprecated.'); +expectedDeprecationWarnings.push(['crypto.DEFAULT_ENCODING is deprecated.', + 'DEP0091']); common.expectWarning({ Warning: expectedWarnings, diff --git a/test/parallel/test-crypto-cipher-decipher.js b/test/parallel/test-crypto-cipher-decipher.js index 75ed26c1ff9..89d070aaa82 100644 --- a/test/parallel/test-crypto-cipher-decipher.js +++ b/test/parallel/test-crypto-cipher-decipher.js @@ -236,7 +236,8 @@ testCipher2(Buffer.from('0123456789abcdef')); const data = Buffer.from('test-crypto-cipher-decipher'); common.expectWarning('Warning', - 'Use Cipheriv for counter mode of aes-256-gcm'); + 'Use Cipheriv for counter mode of aes-256-gcm', + common.noWarnCode); const cipher = crypto.createCipher('aes-256-gcm', key); cipher.setAAD(aadbuf); diff --git a/test/parallel/test-crypto-deprecated.js b/test/parallel/test-crypto-deprecated.js index d8f2be43693..2a9246a2e0b 100644 --- a/test/parallel/test-crypto-deprecated.js +++ b/test/parallel/test-crypto-deprecated.js @@ -8,10 +8,12 @@ const crypto = require('crypto'); const tls = require('tls'); common.expectWarning('DeprecationWarning', [ - 'crypto.Credentials is deprecated. Use tls.SecureContext instead.', - 'crypto.createCredentials is deprecated. Use tls.createSecureContext ' + - 'instead.', - 'crypto.Decipher.finaltol is deprecated. Use crypto.Decipher.final instead.' + ['crypto.Credentials is deprecated. Use tls.SecureContext instead.', + 'DEP0011'], + ['crypto.createCredentials is deprecated. Use tls.createSecureContext ' + + 'instead.', 'DEP0010'], + ['crypto.Decipher.finaltol is deprecated. Use crypto.Decipher.final instead.', + 'DEP0105'] ]); // Accessing the deprecated function is enough to trigger the warning event. diff --git a/test/parallel/test-fs-filehandle.js b/test/parallel/test-fs-filehandle.js index 761193b6d29..8ddc11ec3e0 100644 --- a/test/parallel/test-fs-filehandle.js +++ b/test/parallel/test-fs-filehandle.js @@ -20,7 +20,8 @@ let fdnum; common.expectWarning( 'Warning', - `Closing file descriptor ${fdnum} on garbage collection` + `Closing file descriptor ${fdnum} on garbage collection`, + common.noWarnCode ); gc(); // eslint-disable-line no-undef diff --git a/test/parallel/test-fs-truncate-fd.js b/test/parallel/test-fs-truncate-fd.js index ee6f66f720a..62634aed1d9 100644 --- a/test/parallel/test-fs-truncate-fd.js +++ b/test/parallel/test-fs-truncate-fd.js @@ -15,7 +15,7 @@ const msg = 'Using fs.truncate with a file descriptor is deprecated.' + ' Please use fs.ftruncate with a file descriptor instead.'; -common.expectWarning('DeprecationWarning', msg); +common.expectWarning('DeprecationWarning', msg, 'DEP0081'); fs.truncate(fd, 5, common.mustCall(function(err) { assert.ok(!err); assert.strictEqual(fs.readFileSync(filename, 'utf8'), 'hello'); diff --git a/test/parallel/test-fs-truncate.js b/test/parallel/test-fs-truncate.js index bb6b4bc8b5d..62da52b38e1 100644 --- a/test/parallel/test-fs-truncate.js +++ b/test/parallel/test-fs-truncate.js @@ -64,8 +64,8 @@ fs.ftruncateSync(fd); stat = fs.statSync(filename); assert.strictEqual(stat.size, 0); -// Check truncateSync -common.expectWarning('DeprecationWarning', msg); +// truncateSync +common.expectWarning('DeprecationWarning', msg, 'DEP0081'); fs.truncateSync(fd); fs.closeSync(fd); diff --git a/test/parallel/test-net-server-connections.js b/test/parallel/test-net-server-connections.js index c424d2a729f..9e1213ada55 100644 --- a/test/parallel/test-net-server-connections.js +++ b/test/parallel/test-net-server-connections.js @@ -30,7 +30,7 @@ const server = new net.Server(); const expectedWarning = 'Server.connections property is deprecated. ' + 'Use Server.getConnections method instead.'; -common.expectWarning('DeprecationWarning', expectedWarning); +common.expectWarning('DeprecationWarning', expectedWarning, 'DEP0020'); // test that server.connections property is no longer enumerable now that it // has been marked as deprecated diff --git a/test/parallel/test-performance-warning.js b/test/parallel/test-performance-warning.js index f3104677a7c..6a7d6f7b944 100644 --- a/test/parallel/test-performance-warning.js +++ b/test/parallel/test-performance-warning.js @@ -20,10 +20,10 @@ performance.maxEntries = 1; ); }); -common.expectWarning('Warning', [ - 'Possible perf_hooks memory leak detected. There are 2 entries in the ' + +common.expectWarning('Warning', 'Possible perf_hooks memory leak detected. ' + + 'There are 2 entries in the ' + 'Performance Timeline. Use the clear methods to remove entries that are no ' + 'longer needed or set performance.maxEntries equal to a higher value ' + - '(currently the maxEntries is 1).']); + '(currently the maxEntries is 1).', common.noWarnCode); performance.mark('test'); diff --git a/test/parallel/test-process-assert.js b/test/parallel/test-process-assert.js index 659fa8ed7ab..74792eebb7b 100644 --- a/test/parallel/test-process-assert.js +++ b/test/parallel/test-process-assert.js @@ -4,7 +4,8 @@ const assert = require('assert'); common.expectWarning( 'DeprecationWarning', - 'process.assert() is deprecated. Please use the `assert` module instead.' + 'process.assert() is deprecated. Please use the `assert` module instead.', + 'DEP0100' ); assert.strictEqual(process.assert(1, 'error'), undefined); diff --git a/test/parallel/test-process-emit-warning-from-native.js b/test/parallel/test-process-emit-warning-from-native.js index d50ea3962bd..d3e2454ada3 100644 --- a/test/parallel/test-process-emit-warning-from-native.js +++ b/test/parallel/test-process-emit-warning-from-native.js @@ -12,7 +12,8 @@ const key = '0123456789'; { common.expectWarning('Warning', - 'Use Cipheriv for counter mode of aes-256-gcm'); + 'Use Cipheriv for counter mode of aes-256-gcm', + common.noWarnCode); // Emits regular warning expected by expectWarning() crypto.createCipher('aes-256-gcm', key); diff --git a/test/parallel/test-process-env-deprecation.js b/test/parallel/test-process-env-deprecation.js index 310023fba77..68817b320b4 100644 --- a/test/parallel/test-process-env-deprecation.js +++ b/test/parallel/test-process-env-deprecation.js @@ -8,7 +8,8 @@ common.expectWarning( 'DeprecationWarning', 'Assigning any value other than a string, number, or boolean to a ' + 'process.env property is deprecated. Please make sure to convert the value ' + - 'to a string before setting process.env with it.' + 'to a string before setting process.env with it.', + 'DEP0104' ); process.env.ABC = undefined; diff --git a/test/parallel/test-promises-unhandled-proxy-rejections.js b/test/parallel/test-promises-unhandled-proxy-rejections.js index f632857d637..dfd1ee322a6 100644 --- a/test/parallel/test-promises-unhandled-proxy-rejections.js +++ b/test/parallel/test-promises-unhandled-proxy-rejections.js @@ -1,16 +1,16 @@ 'use strict'; const common = require('../common'); -const expectedDeprecationWarning = 'Unhandled promise rejections are ' + +const expectedDeprecationWarning = ['Unhandled promise rejections are ' + 'deprecated. In the future, promise ' + 'rejections that are not handled will ' + 'terminate the Node.js process with a ' + - 'non-zero exit code.'; -const expectedPromiseWarning = 'Unhandled promise rejection. ' + + 'non-zero exit code.', 'DEP0018']; +const expectedPromiseWarning = ['Unhandled promise rejection. ' + 'This error originated either by throwing ' + 'inside of an async function without a catch ' + 'block, or by rejecting a promise which was ' + - 'not handled with .catch(). (rejection id: 1)'; + 'not handled with .catch(). (rejection id: 1)', common.noWarnCode]; function throwErr() { throw new Error('Error from proxy'); diff --git a/test/parallel/test-promises-unhandled-symbol-rejections.js b/test/parallel/test-promises-unhandled-symbol-rejections.js index 3e687d4e49b..5c028a74c24 100644 --- a/test/parallel/test-promises-unhandled-symbol-rejections.js +++ b/test/parallel/test-promises-unhandled-symbol-rejections.js @@ -1,17 +1,17 @@ 'use strict'; const common = require('../common'); -const expectedValueWarning = 'Symbol()'; -const expectedDeprecationWarning = 'Unhandled promise rejections are ' + +const expectedValueWarning = ['Symbol()', common.noWarnCode]; +const expectedDeprecationWarning = ['Unhandled promise rejections are ' + 'deprecated. In the future, promise ' + 'rejections that are not handled will ' + 'terminate the Node.js process with a ' + - 'non-zero exit code.'; -const expectedPromiseWarning = 'Unhandled promise rejection. ' + + 'non-zero exit code.', common.noWarnCode]; +const expectedPromiseWarning = ['Unhandled promise rejection. ' + 'This error originated either by throwing ' + 'inside of an async function without a catch ' + 'block, or by rejecting a promise which was ' + - 'not handled with .catch(). (rejection id: 1)'; + 'not handled with .catch(). (rejection id: 1)', common.noWarnCode]; common.expectWarning({ DeprecationWarning: expectedDeprecationWarning, diff --git a/test/parallel/test-repl-deprecations.js b/test/parallel/test-repl-deprecations.js index c2a97ad7aca..dbd50eb469f 100644 --- a/test/parallel/test-repl-deprecations.js +++ b/test/parallel/test-repl-deprecations.js @@ -9,7 +9,7 @@ function testParseREPLKeyword() { const server = repl.start({ prompt: '> ' }); const warn = 'REPLServer.parseREPLKeyword() is deprecated'; - common.expectWarning('DeprecationWarning', warn); + common.expectWarning('DeprecationWarning', warn, 'DEP0075'); assert.ok(server.parseREPLKeyword('clear')); assert.ok(!server.parseREPLKeyword('tacos')); server.close(); diff --git a/test/parallel/test-repl-memory-deprecation.js b/test/parallel/test-repl-memory-deprecation.js index 9993360a286..07d377d8fbf 100644 --- a/test/parallel/test-repl-memory-deprecation.js +++ b/test/parallel/test-repl-memory-deprecation.js @@ -9,7 +9,7 @@ function testMemory() { const server = repl.start({ prompt: '> ' }); const warn = 'REPLServer.memory() is deprecated'; - common.expectWarning('DeprecationWarning', warn); + common.expectWarning('DeprecationWarning', warn, 'DEP0082'); assert.strictEqual(server.memory(), undefined); server.close(); } diff --git a/test/parallel/test-repl-turn-off-editor-mode.js b/test/parallel/test-repl-turn-off-editor-mode.js index c98520c9ec4..a966899b2c6 100644 --- a/test/parallel/test-repl-turn-off-editor-mode.js +++ b/test/parallel/test-repl-turn-off-editor-mode.js @@ -8,7 +8,7 @@ function testTurnOffEditorMode() { const server = repl.start({ prompt: '> ' }); const warn = 'REPLServer.turnOffEditorMode() is deprecated'; - common.expectWarning('DeprecationWarning', warn); + common.expectWarning('DeprecationWarning', warn, 'DEP0078'); server.turnOffEditorMode(); server.close(); } diff --git a/test/parallel/test-require-deps-deprecation.js b/test/parallel/test-require-deps-deprecation.js index b588fa4da9e..24a2e86e6a4 100644 --- a/test/parallel/test-require-deps-deprecation.js +++ b/test/parallel/test-require-deps-deprecation.js @@ -29,8 +29,8 @@ const deps = [ ]; common.expectWarning('DeprecationWarning', deprecatedModules.map((m) => { - return `Requiring Node.js-bundled '${m}' module is deprecated. ` + - 'Please install the necessary module locally.'; + return [`Requiring Node.js-bundled '${m}' module is deprecated. ` + + 'Please install the necessary module locally.', 'DEP0084']; })); for (const m of deprecatedModules) { diff --git a/test/parallel/test-tls-dhe.js b/test/parallel/test-tls-dhe.js index 177f6f2eb2d..9fbd8d980c2 100644 --- a/test/parallel/test-tls-dhe.js +++ b/test/parallel/test-tls-dhe.js @@ -41,7 +41,8 @@ const ciphers = 'DHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256'; // Test will emit a warning because the DH parameter size is < 2048 bits common.expectWarning('SecurityWarning', - 'DH parameter is less than 2048 bits'); + 'DH parameter is less than 2048 bits', + common.noWarnCode); function loadDHParam(n) { const params = [`dh${n}.pem`]; diff --git a/test/parallel/test-tls-ecdh-disable.js b/test/parallel/test-tls-ecdh-disable.js index 7726a0655ed..1109b71dbe2 100644 --- a/test/parallel/test-tls-ecdh-disable.js +++ b/test/parallel/test-tls-ecdh-disable.js @@ -48,7 +48,8 @@ const options = { }; common.expectWarning('DeprecationWarning', - '{ ecdhCurve: false } is deprecated.'); + '{ ecdhCurve: false } is deprecated.', + 'DEP0083'); const server = tls.createServer(options, common.mustNotCall()); diff --git a/test/parallel/test-tls-legacy-deprecated.js b/test/parallel/test-tls-legacy-deprecated.js index c2560daf214..8aa8fd31d2e 100644 --- a/test/parallel/test-tls-legacy-deprecated.js +++ b/test/parallel/test-tls-legacy-deprecated.js @@ -8,7 +8,8 @@ const tls = require('tls'); common.expectWarning( 'DeprecationWarning', - 'tls.createSecurePair() is deprecated. Please use tls.TLSSocket instead.' + 'tls.createSecurePair() is deprecated. Please use tls.TLSSocket instead.', + 'DEP0064' ); tls.createSecurePair(); diff --git a/test/parallel/test-tls-parse-cert-string.js b/test/parallel/test-tls-parse-cert-string.js index 78e570d0889..a0bafe9c528 100644 --- a/test/parallel/test-tls-parse-cert-string.js +++ b/test/parallel/test-tls-parse-cert-string.js @@ -59,7 +59,8 @@ common.restoreStderr(); { common.expectWarning('DeprecationWarning', 'tls.parseCertString() is deprecated. ' + - 'Please use querystring.parse() instead.'); + 'Please use querystring.parse() instead.', + 'DEP0076'); const ret = tls.parseCertString('foo=bar'); assert.deepStrictEqual(ret, { __proto__: null, foo: 'bar' }); diff --git a/test/parallel/test-util-inspect-deprecated.js b/test/parallel/test-util-inspect-deprecated.js index adabb066970..476bda4daa7 100644 --- a/test/parallel/test-util-inspect-deprecated.js +++ b/test/parallel/test-util-inspect-deprecated.js @@ -11,7 +11,8 @@ const util = require('util'); // `common.expectWarning` will expect the warning exactly one time only common.expectWarning( 'DeprecationWarning', - 'Custom inspection function on Objects via .inspect() is deprecated' + 'Custom inspection function on Objects via .inspect() is deprecated', + 'DEP0079' ); util.inspect(target); // should emit deprecation warning util.inspect(target); // should not emit deprecation warning diff --git a/test/parallel/test-util.js b/test/parallel/test-util.js index a60e0d5b537..ee2fe917f3e 100644 --- a/test/parallel/test-util.js +++ b/test/parallel/test-util.js @@ -142,10 +142,10 @@ assert.strictEqual(util.isFunction(), false); assert.strictEqual(util.isFunction('string'), false); common.expectWarning('DeprecationWarning', [ - 'util.print is deprecated. Use console.log instead.', - 'util.puts is deprecated. Use console.log instead.', - 'util.debug is deprecated. Use console.error instead.', - 'util.error is deprecated. Use console.error instead.' + ['util.print is deprecated. Use console.log instead.', common.noWarnCode], + ['util.puts is deprecated. Use console.log instead.', common.noWarnCode], + ['util.debug is deprecated. Use console.error instead.', common.noWarnCode], + ['util.error is deprecated. Use console.error instead.', common.noWarnCode] ]); util.print('test'); diff --git a/test/parallel/test-warn-sigprof.js b/test/parallel/test-warn-sigprof.js index 3404490c2a1..71ac25443bc 100644 --- a/test/parallel/test-warn-sigprof.js +++ b/test/parallel/test-warn-sigprof.js @@ -10,6 +10,7 @@ if (common.isWindows) common.skip('test does not apply to Windows'); common.expectWarning('Warning', - 'process.on(SIGPROF) is reserved while debugging'); + 'process.on(SIGPROF) is reserved while debugging', + common.noWarnCode); process.on('SIGPROF', () => {}); From 0c2cc89f3aab58a118f5e584cbeb4b20a6366cb0 Mon Sep 17 00:00:00 2001 From: "davis.okoth@kemsa.co.ke" Date: Thu, 22 Mar 2018 22:04:38 +0300 Subject: [PATCH 07/10] test: remove third param from assert.strictEqual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Removing third argument in calls to assert.strictEqual() so that the values of the first two arguments are shown instead as this is more useful for debugging. Refs: https://nodejs.org/api/assert.html#assert_assert_strictequal_actual_expected_message PR-URL: https://github.com/nodejs/node/pull/19536 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott Reviewed-By: Richard Lau Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat Reviewed-By: Franziska Hinkelmann Reviewed-By: Tobias Nießen --- test/parallel/test-fs-mkdir-rmdir.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-fs-mkdir-rmdir.js b/test/parallel/test-fs-mkdir-rmdir.js index 6427dbd3403..ff0da82bdf7 100644 --- a/test/parallel/test-fs-mkdir-rmdir.js +++ b/test/parallel/test-fs-mkdir-rmdir.js @@ -32,8 +32,8 @@ fs.mkdir(d, 0o666, common.mustCall(function(err) { assert.strictEqual(this, undefined); assert.ok(err, 'got no error'); assert.ok(/^EEXIST/.test(err.message), 'got no EEXIST message'); - assert.strictEqual(err.code, 'EEXIST', 'got no EEXIST code'); - assert.strictEqual(err.path, d, 'got no proper path for EEXIST'); + assert.strictEqual(err.code, 'EEXIST'); + assert.strictEqual(err.path, d); fs.rmdir(d, assert.ifError); })); From d6664eb3d7aa5c63b64a8ca856ddbd14304562bd Mon Sep 17 00:00:00 2001 From: Beth Griggs Date: Mon, 26 Mar 2018 12:36:46 +0100 Subject: [PATCH 08/10] doc: add BethGriggs to collaborators PR-URL: https://github.com/nodejs/node/pull/19610 Reviewed-By: Anna Henningsen Reviewed-By: Gibson Fahnestock Reviewed-By: Gireesh Punathil Reviewed-By: Colin Ihrig Reviewed-By: Yuta Hiroto Reviewed-By: Ruben Bridgewater Reviewed-By: Richard Lau Reviewed-By: Vse Mozhet Byt Reviewed-By: Joyee Cheung --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index b1f51c7098b..7342012dc0e 100644 --- a/README.md +++ b/README.md @@ -314,6 +314,8 @@ For more information about the governance of the Node.js project, see **Bryan English** <bryan@bryanenglish.com> (he/him) * [benjamingr](https://github.com/benjamingr) - **Benjamin Gruenbaum** <benjamingr@gmail.com> +* [BethGriggs](https://github.com/BethGriggs) - +**Beth Griggs** <Bethany.Griggs@uk.ibm.com> (she/her) * [bmeck](https://github.com/bmeck) - **Bradley Farias** <bradley.meck@gmail.com> * [bmeurer](https://github.com/bmeurer) - From 189eaa043535c27cde96a863a2f90785913b1071 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 23 Mar 2018 12:54:48 +0100 Subject: [PATCH 09/10] doc: remove confusing note about child process stdio MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s not obvious what the paragraph is supposed to say. In particular, whether and what kind of buffering mechanism a process uses for its stdio streams does not affect that, in general, no guarantees can be made about when it consumes data that was sent to it. PR-URL: https://github.com/nodejs/node/pull/19552 Reviewed-By: Rich Trott Reviewed-By: Trivikram Kamat Reviewed-By: James M Snell --- doc/api/child_process.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 09e43b2bd47..6def24c8a57 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -33,10 +33,6 @@ stdout in excess of that limit without the output being captured, the child process will block waiting for the pipe buffer to accept more data. This is identical to the behavior of pipes in the shell. Use the `{ stdio: 'ignore' }` option if the output will not be consumed. -It is possible to stream data through these pipes in a non-blocking way. Note, -however, that some programs use line-buffered I/O internally. While that does -not affect Node.js, it can mean that data sent to the child process may not be -immediately consumed. The [`child_process.spawn()`][] method spawns the child process asynchronously, without blocking the Node.js event loop. The [`child_process.spawnSync()`][] From 9396b77238434f21585cfc198d7809ebf27729cf Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Sun, 25 Mar 2018 19:56:02 -0700 Subject: [PATCH 10/10] doc: rename HTTP2 to HTTP/2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, "HTTP/2" was strictly used to describe the protocol, and HTTP2 the module. This distinction is deemed unnecessary, and consistency between the two terms is enforced. PR-URL: https://github.com/nodejs/node/pull/19603 Reviewed-By: Vse Mozhet Byt Reviewed-By: James M Snell Reviewed-By: Tobias Nießen Reviewed-By: Colin Ihrig Reviewed-By: Trivikram Kamat Reviewed-By: Chen Gang Reviewed-By: Shingo Inoue --- doc/api/http2.md | 60 ++++++++++++++++++++-------------------- tools/doc/type-parser.js | 4 +-- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/doc/api/http2.md b/doc/api/http2.md index 050ef5d0b22..8698af204cf 100644 --- a/doc/api/http2.md +++ b/doc/api/http2.md @@ -1,4 +1,4 @@ -# HTTP2 +# HTTP/2 @@ -229,7 +229,7 @@ added: v8.4.0 The `'stream'` event is emitted when a new `Http2Stream` is created. When invoked, the handler function will receive a reference to the `Http2Stream` -object, a [HTTP2 Headers Object][], and numeric flags associated with the +object, a [HTTP/2 Headers Object][], and numeric flags associated with the creation of the stream. ```js @@ -381,7 +381,7 @@ Transmits a `GOAWAY` frame to the connected peer *without* shutting down the added: v8.4.0 --> -* Value: {HTTP2 Settings Object} +* Value: {HTTP/2 Settings Object} A prototype-less object describing the current local settings of this `Http2Session`. The local settings are local to *this* `Http2Session` instance. @@ -460,7 +460,7 @@ instance's underlying [`net.Socket`]. added: v8.4.0 --> -* Value: {HTTP2 Settings Object} +* Value: {HTTP/2 Settings Object} A prototype-less object describing the current remote settings of this `Http2Session`. The remote settings are set by the *connected* HTTP/2 peer. @@ -530,7 +530,7 @@ An object describing the current status of this `Http2Session`. added: v8.4.0 --> -* `settings` {HTTP2 Settings Object} +* `settings` {HTTP/2 Settings Object} Updates the current local settings for this `Http2Session` and sends a new `SETTINGS` frame to the connected HTTP/2 peer. @@ -669,7 +669,7 @@ client.on('altsvc', (alt, origin, streamId) => { added: v8.4.0 --> -* `headers` {HTTP2 Headers Object} +* `headers` {HTTP/2 Headers Object} * `options` {Object} * `endStream` {boolean} `true` if the `Http2Stream` *writable* side should be closed initially, such as when sending a `GET` request that should not @@ -855,7 +855,7 @@ added: v8.4.0 The `'trailers'` event is emitted when a block of headers associated with trailing header fields is received. The listener callback is passed the -[HTTP2 Headers Object][] and flags associated with the headers. +[HTTP/2 Headers Object][] and flags associated with the headers. ```js stream.on('trailers', (headers, flags) => { @@ -952,7 +952,7 @@ calling `http2stream.close()`, or `http2stream.destroy()`. Will be added: v9.5.0 --> -* Value: {HTTP2 Headers Object} +* Value: {HTTP/2 Headers Object} An object containing the outbound headers sent for this `Http2Stream`. @@ -961,7 +961,7 @@ An object containing the outbound headers sent for this `Http2Stream`. added: v9.5.0 --> -* Value: {HTTP2 Headers Object[]} +* Value: {HTTP/2 Headers Object[]} An array of objects containing the outbound informational (additional) headers sent for this `Http2Stream`. @@ -971,7 +971,7 @@ sent for this `Http2Stream`. added: v9.5.0 --> -* Value: {HTTP2 Headers Object} +* Value: {HTTP/2 Headers Object} An object containing the outbound trailers sent for this this `HttpStream`. @@ -1053,7 +1053,7 @@ added: v8.4.0 The `'headers'` event is emitted when an additional block of headers is received for a stream, such as when a block of `1xx` informational headers is received. -The listener callback is passed the [HTTP2 Headers Object][] and flags +The listener callback is passed the [HTTP/2 Headers Object][] and flags associated with the headers. ```js @@ -1068,7 +1068,7 @@ added: v8.4.0 --> The `'push'` event is emitted when response headers for a Server Push stream -are received. The listener callback is passed the [HTTP2 Headers Object][] and +are received. The listener callback is passed the [HTTP/2 Headers Object][] and flags associated with the headers. ```js @@ -1085,7 +1085,7 @@ added: v8.4.0 The `'response'` event is emitted when a response `HEADERS` frame has been received for this stream from the connected HTTP/2 server. The listener is invoked with two arguments: an Object containing the received -[HTTP2 Headers Object][], and flags associated with the headers. +[HTTP/2 Headers Object][], and flags associated with the headers. ```js const http2 = require('http2'); @@ -1113,7 +1113,7 @@ provide additional methods such as `http2stream.pushStream()` and added: v8.4.0 --> -* `headers` {HTTP2 Headers Object} +* `headers` {HTTP/2 Headers Object} Sends an additional informational `HEADERS` frame to the connected HTTP/2 peer. @@ -1143,7 +1143,7 @@ accepts push streams, `false` otherwise. Settings are the same for every added: v8.4.0 --> -* `headers` {HTTP2 Headers Object} +* `headers` {HTTP/2 Headers Object} * `options` {Object} * `exclusive` {boolean} When `true` and `parent` identifies a parent Stream, the created stream is made the sole direct dependency of the parent, with @@ -1155,7 +1155,7 @@ added: v8.4.0 initiated. * `err` {Error} * `pushStream` {ServerHttp2Stream} The returned pushStream object. - * `headers` {HTTP2 Headers Object} Headers object the pushStream was + * `headers` {HTTP/2 Headers Object} Headers object the pushStream was initiated with. Initiates a push stream. The callback is invoked with the new `Http2Stream` @@ -1185,7 +1185,7 @@ a `weight` value to `http2stream.priority` with the `silent` option set to added: v8.4.0 --> -* `headers` {HTTP2 Headers Object} +* `headers` {HTTP/2 Headers Object} * `options` {Object} * `endStream` {boolean} Set to `true` to indicate that the response will not include payload data. @@ -1234,7 +1234,7 @@ changes: --> * `fd` {number} A readable file descriptor. -* `headers` {HTTP2 Headers Object} +* `headers` {HTTP/2 Headers Object} * `options` {Object} * `statCheck` {Function} * `getTrailers` {Function} Callback function invoked to collect trailer @@ -1329,7 +1329,7 @@ changes: --> * `path` {string|Buffer|URL} -* `headers` {HTTP2 Headers Object} +* `headers` {HTTP/2 Headers Object} * `options` {Object} * `statCheck` {Function} * `onError` {Function} Callback function invoked in the case of an @@ -1708,7 +1708,7 @@ changes: * `selectPadding` {Function} When `options.paddingStrategy` is equal to `http2.constants.PADDING_STRATEGY_CALLBACK`, provides the callback function used to determine the padding. See [Using options.selectPadding][]. - * `settings` {HTTP2 Settings Object} The initial settings to send to the + * `settings` {HTTP/2 Settings Object} The initial settings to send to the remote peer upon connection. * `Http1IncomingMessage` {http.IncomingMessage} Specifies the IncomingMessage class to used for HTTP/1 fallback. Useful for extending the original @@ -1817,7 +1817,7 @@ changes: * `selectPadding` {Function} When `options.paddingStrategy` is equal to `http2.constants.PADDING_STRATEGY_CALLBACK`, provides the callback function used to determine the padding. See [Using options.selectPadding][]. - * `settings` {HTTP2 Settings Object} The initial settings to send to the + * `settings` {HTTP/2 Settings Object} The initial settings to send to the remote peer upon connection. * ...: Any [`tls.createServer()`][] options can be provided. For servers, the identity options (`pfx` or `key`/`cert`) are usually required. @@ -1913,7 +1913,7 @@ changes: * `selectPadding` {Function} When `options.paddingStrategy` is equal to `http2.constants.PADDING_STRATEGY_CALLBACK`, provides the callback function used to determine the padding. See [Using options.selectPadding][]. - * `settings` {HTTP2 Settings Object} The initial settings to send to the + * `settings` {HTTP/2 Settings Object} The initial settings to send to the remote peer upon connection. * `createConnection` {Function} An optional callback that receives the `URL` instance passed to `connect` and the `options` object, and returns any @@ -1966,7 +1966,7 @@ a given number of milliseconds set using `http2server.setTimeout()`. added: v8.4.0 --> -* Returns: {HTTP2 Settings Object} +* Returns: {HTTP/2 Settings Object} Returns an object containing the default settings for an `Http2Session` instance. This method returns a new object instance every time it is called @@ -1977,7 +1977,7 @@ so instances returned may be safely modified for use. added: v8.4.0 --> -* `settings` {HTTP2 Settings Object} +* `settings` {HTTP/2 Settings Object} * Returns: {Buffer} Returns a `Buffer` instance containing serialized representation of the given @@ -1999,9 +1999,9 @@ added: v8.4.0 --> * `buf` {Buffer|Uint8Array} The packed settings. -* Returns: {HTTP2 Settings Object} +* Returns: {HTTP/2 Settings Object} -Returns a [HTTP2 Settings Object][] containing the deserialized settings from +Returns a [HTTP/2 Settings Object][] containing the deserialized settings from the given `Buffer` as generated by `http2.getPackedSettings()`. ### Headers Object @@ -2262,7 +2262,7 @@ In order to create a mixed [HTTPS][] and HTTP/2 server, refer to the [ALPN negotiation][] section. Upgrading from non-tls HTTP/1 servers is not supported. -The HTTP2 compatibility API is composed of [`Http2ServerRequest`]() and +The HTTP/2 compatibility API is composed of [`Http2ServerRequest`]() and [`Http2ServerResponse`](). They aim at API compatibility with HTTP/1, but they do not hide the differences between the protocols. As an example, the status message for HTTP codes is ignored. @@ -2370,7 +2370,7 @@ Example: console.log(request.headers); ``` -See [HTTP2 Headers Object][]. +See [HTTP/2 Headers Object][]. In HTTP/2, the request path, hostname, protocol, and method are represented as special headers prefixed with the `:` character (e.g. `':path'`). These special @@ -3097,8 +3097,8 @@ following additional properties: [HTTP/1]: http.html [HTTP/2]: https://tools.ietf.org/html/rfc7540 [HTTP/2 Unencrypted]: https://http2.github.io/faq/#does-http2-require-encryption -[HTTP2 Headers Object]: #http2_headers_object -[HTTP2 Settings Object]: #http2_settings_object +[HTTP/2 Headers Object]: #http2_headers_object +[HTTP/2 Settings Object]: #http2_settings_object [HTTPS]: https.html [Http2Session and Sockets]: #http2_http2session_and_sockets [Performance Observer]: perf_hooks.html diff --git a/tools/doc/type-parser.js b/tools/doc/type-parser.js index 1a7698ad6a3..e42b23bdea6 100644 --- a/tools/doc/type-parser.js +++ b/tools/doc/type-parser.js @@ -55,8 +55,8 @@ const typeMap = { 'http.ServerResponse': 'http.html#http_class_http_serverresponse', 'ClientHttp2Stream': 'http2.html#http2_class_clienthttp2stream', - 'HTTP2 Headers Object': 'http2.html#http2_headers_object', - 'HTTP2 Settings Object': 'http2.html#http2_settings_object', + 'HTTP/2 Headers Object': 'http2.html#http2_headers_object', + 'HTTP/2 Settings Object': 'http2.html#http2_settings_object', 'http2.Http2ServerRequest': 'http2.html#http2_class_http2_http2serverrequest', 'http2.Http2ServerResponse': 'http2.html#http2_class_http2_http2serverresponse',