From 36993c05667bbfda66d84329278b82887771cc94 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Fri, 24 Apr 2020 15:45:51 +0200 Subject: [PATCH 01/20] buffer,n-api: fix double ArrayBuffer::Detach() during cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These calls could fail if the `ArrayBuffer` had already been explicitly detached at some point in the past. The necessary test changes already came with 4f523c2c1a1c and could be ported back to v12.x with a backport of this PR. Fixes: https://github.com/nodejs/node/issues/33022 Refs: https://github.com/nodejs/node/pull/30551 PR-URL: https://github.com/nodejs/node/pull/33039 Reviewed-By: James M Snell Reviewed-By: Chengzhong Wu Reviewed-By: Michael Dawson Reviewed-By: Gerhard Stöbich Reviewed-By: David Carlier Reviewed-By: Juan José Arboleda --- src/js_native_api_v8.cc | 10 ++++++---- src/node_buffer.cc | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/js_native_api_v8.cc b/src/js_native_api_v8.cc index ef25c92e060592..4255c3e7ec3fff 100644 --- a/src/js_native_api_v8.cc +++ b/src/js_native_api_v8.cc @@ -392,10 +392,12 @@ class ArrayBufferReference final : public Reference { inline void Finalize(bool is_env_teardown) override { if (is_env_teardown) { v8::HandleScope handle_scope(_env->isolate); - v8::Local ab = Get(); - CHECK(!ab.IsEmpty()); - CHECK(ab->IsArrayBuffer()); - ab.As()->Detach(); + v8::Local obj = Get(); + CHECK(!obj.IsEmpty()); + CHECK(obj->IsArrayBuffer()); + v8::Local ab = obj.As(); + if (ab->IsDetachable()) + ab->Detach(); } Reference::Finalize(is_env_teardown); diff --git a/src/node_buffer.cc b/src/node_buffer.cc index 77120d6af4a811..1ff60ad721753e 100644 --- a/src/node_buffer.cc +++ b/src/node_buffer.cc @@ -152,7 +152,8 @@ void CallbackInfo::CleanupHook(void* data) { HandleScope handle_scope(self->env_->isolate()); Local ab = self->persistent_.Get(self->env_->isolate()); CHECK(!ab.IsEmpty()); - ab->Detach(); + if (ab->IsDetachable()) + ab->Detach(); } self->WeakCallback(self->env_->isolate()); From b37ec37210237ab65040948791916912c4ab055d Mon Sep 17 00:00:00 2001 From: Ujjwal Sharma Date: Wed, 22 Apr 2020 12:20:17 +0530 Subject: [PATCH 02/20] deps: V8: backport 3f8dc4b2e5ba MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message: [intl] Remove soon-to-be removed getAllFieldPositions Needed to land ICU67.1 soon. Bug: v8:10393 Change-Id: I3c7737ca600d6ccfdc46ffaddfb318ce60bc7618 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2136489 Reviewed-by: Jakob Kummerow Commit-Queue: Frank Tang Cr-Commit-Position: refs/heads/master@{#67027} Refs: https://github.com/v8/v8/commit/3f8dc4b2e5baf77b463334c769af85b79d8c1463 PR-URL: https://github.com/nodejs/node/pull/32993 Reviewed-By: Michaël Zasso Reviewed-By: Matheus Marchini Reviewed-By: Steven R Loomis Reviewed-By: Richard Lau --- common.gypi | 2 +- deps/v8/src/objects/js-number-format.cc | 72 +++++++++++++------------ 2 files changed, 38 insertions(+), 36 deletions(-) diff --git a/common.gypi b/common.gypi index b23898301a4898..4dfbdfac061887 100644 --- a/common.gypi +++ b/common.gypi @@ -35,7 +35,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.13', + 'v8_embedder_string': '-node.14', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/objects/js-number-format.cc b/deps/v8/src/objects/js-number-format.cc index 92d3e2fb82eaed..ced408aa173d92 100644 --- a/deps/v8/src/objects/js-number-format.cc +++ b/deps/v8/src/objects/js-number-format.cc @@ -1197,42 +1197,31 @@ MaybeHandle JSNumberFormat::New(Isolate* isolate, } namespace { -Maybe IcuFormatNumber( +Maybe IcuFormatNumber( Isolate* isolate, const icu::number::LocalizedNumberFormatter& number_format, - Handle numeric_obj, icu::FieldPositionIterator* fp_iter) { + Handle numeric_obj, icu::number::FormattedNumber* formatted) { // If it is BigInt, handle it differently. UErrorCode status = U_ZERO_ERROR; - icu::number::FormattedNumber formatted; if (numeric_obj->IsBigInt()) { Handle big_int = Handle::cast(numeric_obj); Handle big_int_string; ASSIGN_RETURN_ON_EXCEPTION_VALUE(isolate, big_int_string, BigInt::ToString(isolate, big_int), - Nothing()); - formatted = number_format.formatDecimal( + Nothing()); + *formatted = number_format.formatDecimal( {big_int_string->ToCString().get(), big_int_string->length()}, status); } else { double number = numeric_obj->Number(); - formatted = number_format.formatDouble(number, status); + *formatted = number_format.formatDouble(number, status); } if (U_FAILURE(status)) { // This happen because of icu data trimming trim out "unit". // See https://bugs.chromium.org/p/v8/issues/detail?id=8641 - THROW_NEW_ERROR_RETURN_VALUE(isolate, - NewTypeError(MessageTemplate::kIcuError), - Nothing()); - } - if (fp_iter) { - formatted.getAllFieldPositions(*fp_iter, status); + THROW_NEW_ERROR_RETURN_VALUE( + isolate, NewTypeError(MessageTemplate::kIcuError), Nothing()); } - icu::UnicodeString result = formatted.toString(status); - if (U_FAILURE(status)) { - THROW_NEW_ERROR_RETURN_VALUE(isolate, - NewTypeError(MessageTemplate::kIcuError), - Nothing()); - } - return Just(result); + return Just(true); } } // namespace @@ -1243,10 +1232,16 @@ MaybeHandle JSNumberFormat::FormatNumeric( Handle numeric_obj) { DCHECK(numeric_obj->IsNumeric()); - Maybe maybe_format = - IcuFormatNumber(isolate, number_format, numeric_obj, nullptr); + icu::number::FormattedNumber formatted; + Maybe maybe_format = + IcuFormatNumber(isolate, number_format, numeric_obj, &formatted); MAYBE_RETURN(maybe_format, Handle()); - return Intl::ToString(isolate, maybe_format.FromJust()); + UErrorCode status = U_ZERO_ERROR; + icu::UnicodeString result = formatted.toString(status); + if (U_FAILURE(status)) { + THROW_NEW_ERROR(isolate, NewTypeError(MessageTemplate::kIcuError), String); + } + return Intl::ToString(isolate, result); } namespace { @@ -1359,12 +1354,18 @@ std::vector FlattenRegionsToParts( } namespace { -Maybe ConstructParts(Isolate* isolate, const icu::UnicodeString& formatted, - icu::FieldPositionIterator* fp_iter, +Maybe ConstructParts(Isolate* isolate, + icu::number::FormattedNumber* formatted, Handle result, int start_index, Handle numeric_obj, bool style_is_unit) { + UErrorCode status = U_ZERO_ERROR; + icu::UnicodeString formatted_text = formatted->toString(status); + if (U_FAILURE(status)) { + THROW_NEW_ERROR_RETURN_VALUE( + isolate, NewTypeError(MessageTemplate::kIcuError), Nothing()); + } DCHECK(numeric_obj->IsNumeric()); - int32_t length = formatted.length(); + int32_t length = formatted_text.length(); int index = start_index; if (length == 0) return Just(index); @@ -1373,13 +1374,14 @@ Maybe ConstructParts(Isolate* isolate, const icu::UnicodeString& formatted, // other region covers some part of the formatted string. It's possible // there's another field with exactly the same begin and end as this backdrop, // in which case the backdrop's field_id of -1 will give it lower priority. - regions.push_back(NumberFormatSpan(-1, 0, formatted.length())); + regions.push_back(NumberFormatSpan(-1, 0, formatted_text.length())); { - icu::FieldPosition fp; - while (fp_iter->next(fp)) { - regions.push_back(NumberFormatSpan(fp.getField(), fp.getBeginIndex(), - fp.getEndIndex())); + icu::ConstrainedFieldPosition cfp; + cfp.constrainCategory(UFIELD_CATEGORY_NUMBER); + while (formatted->nextPosition(cfp, status)) { + regions.push_back( + NumberFormatSpan(cfp.getField(), cfp.getStart(), cfp.getLimit())); } } @@ -1401,7 +1403,7 @@ Maybe ConstructParts(Isolate* isolate, const icu::UnicodeString& formatted, Handle substring; ASSIGN_RETURN_ON_EXCEPTION_VALUE( isolate, substring, - Intl::ToString(isolate, formatted, part.begin_pos, part.end_pos), + Intl::ToString(isolate, formatted_text, part.begin_pos, part.end_pos), Nothing()); Intl::AddElement(isolate, result, index, field_type_string, substring); ++index; @@ -1421,14 +1423,14 @@ MaybeHandle JSNumberFormat::FormatToParts( number_format->icu_number_formatter().raw(); CHECK_NOT_NULL(fmt); - icu::FieldPositionIterator fp_iter; - Maybe maybe_format = - IcuFormatNumber(isolate, *fmt, numeric_obj, &fp_iter); + icu::number::FormattedNumber formatted; + Maybe maybe_format = + IcuFormatNumber(isolate, *fmt, numeric_obj, &formatted); MAYBE_RETURN(maybe_format, Handle()); Handle result = factory->NewJSArray(0); Maybe maybe_format_to_parts = ConstructParts( - isolate, maybe_format.FromJust(), &fp_iter, result, 0, numeric_obj, + isolate, &formatted, result, 0, numeric_obj, number_format->style() == JSNumberFormat::Style::UNIT); MAYBE_RETURN(maybe_format_to_parts, Handle()); From 58682d823acb0e566f16d1d8b33b83dfebf3aa5d Mon Sep 17 00:00:00 2001 From: rickyes Date: Sun, 12 Apr 2020 02:07:35 +0800 Subject: [PATCH 03/20] tls: add highWaterMark option for connect PR-URL: https://github.com/nodejs/node/pull/32786 Fixes: https://github.com/nodejs/node/issues/32781 Reviewed-By: Zeyu Yang Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Andrey Pechkurov --- doc/api/https.md | 6 +- doc/api/tls.md | 5 ++ lib/_tls_wrap.js | 4 +- test/parallel/test-https-hwm.js | 66 ++++++++++++++++++++ test/parallel/test-tls-connect-hwm-option.js | 53 ++++++++++++++++ 5 files changed, 132 insertions(+), 2 deletions(-) create mode 100644 test/parallel/test-https-hwm.js create mode 100644 test/parallel/test-tls-connect-hwm-option.js diff --git a/doc/api/https.md b/doc/api/https.md index ac53b6f0fdeccf..2b19831e9e907c 100644 --- a/doc/api/https.md +++ b/doc/api/https.md @@ -238,6 +238,9 @@ Global instance of [`https.Agent`][] for all HTTPS client requests. * `stream` {Stream} A readable and/or writable stream. @@ -1580,6 +1595,12 @@ changes: - version: v13.10.0 pr-url: https://github.com/nodejs/node/pull/31223 description: Add support for async generators. + - version: v14.0.0 + pr-url: https://github.com/nodejs/node/pull/32158 + description: The `pipeline(..., cb)` will wait for the `'close'` event + before invoking the callback. The implementation tries to + detect legacy streams and only apply this behavior to streams + which are expected to emit `'close'`. --> * `source` {Stream|Iterable|AsyncIterable|Function} From a8236e0f710c9b28febca6e4294f751b11ad72a9 Mon Sep 17 00:00:00 2001 From: Stephen Belanger Date: Fri, 24 Apr 2020 17:02:07 -0700 Subject: [PATCH 17/20] src: add AsyncWrapObject constructor template factory MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/33051 Reviewed-By: Anna Henningsen Reviewed-By: James M Snell Reviewed-By: Gerhard Stöbich Reviewed-By: David Carlier Reviewed-By: Juan José Arboleda --- src/async_wrap.cc | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/src/async_wrap.cc b/src/async_wrap.cc index b24c160156c280..42837e09818ec2 100644 --- a/src/async_wrap.cc +++ b/src/async_wrap.cc @@ -80,6 +80,20 @@ struct AsyncWrapObject : public AsyncWrap { inline AsyncWrapObject(Environment* env, Local object, ProviderType type) : AsyncWrap(env, object, type) {} + static Local GetConstructorTemplate(Environment* env) { + Local tmpl = env->async_wrap_object_ctor_template(); + if (tmpl.IsEmpty()) { + tmpl = env->NewFunctionTemplate(AsyncWrapObject::New); + tmpl->SetClassName( + FIXED_ONE_BYTE_STRING(env->isolate(), "AsyncWrap")); + tmpl->Inherit(AsyncWrap::GetConstructorTemplate(env)); + tmpl->InstanceTemplate()->SetInternalFieldCount( + AsyncWrapObject::kInternalFieldCount); + env->set_async_wrap_object_ctor_template(tmpl); + } + return tmpl; + } + SET_NO_MEMORY_INFO() SET_MEMORY_INFO_NAME(AsyncWrapObject) SET_SELF_SIZE(AsyncWrapObject) @@ -559,21 +573,10 @@ void AsyncWrap::Initialize(Local target, env->set_async_hooks_promise_resolve_function(Local()); env->set_async_hooks_binding(target); - // TODO(addaleax): This block might better work as a - // AsyncWrapObject::Initialize() or AsyncWrapObject::GetConstructorTemplate() - // function. - { - auto class_name = FIXED_ONE_BYTE_STRING(env->isolate(), "AsyncWrap"); - auto function_template = env->NewFunctionTemplate(AsyncWrapObject::New); - function_template->SetClassName(class_name); - function_template->Inherit(AsyncWrap::GetConstructorTemplate(env)); - auto instance_template = function_template->InstanceTemplate(); - instance_template->SetInternalFieldCount(AsyncWrap::kInternalFieldCount); - auto function = - function_template->GetFunction(env->context()).ToLocalChecked(); - target->Set(env->context(), class_name, function).Check(); - env->set_async_wrap_object_ctor_template(function_template); - } + target->Set(env->context(), + FIXED_ONE_BYTE_STRING(env->isolate(), "AsyncWrap"), + AsyncWrapObject::GetConstructorTemplate(env) + ->GetFunction(env->context()).ToLocalChecked()).Check(); } From 16d794dae64529f908659fca97370760bfd89fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Fri, 24 Apr 2020 19:10:35 +0200 Subject: [PATCH 18/20] doc: improve release documentation Extract the "Cherry-pick the Release Commit to master" part to its own section and be more precise about what should be done to handle conflicts. PR-URL: https://github.com/nodejs/node/pull/33042 Reviewed-By: Anna Henningsen Reviewed-By: Richard Lau Reviewed-By: Michael Dawson Reviewed-By: Myles Borins Reviewed-By: Anto Aravinth Reviewed-By: Beth Griggs --- doc/guides/releases.md | 60 +++++++++++++++++++++++++++--------------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/doc/guides/releases.md b/doc/guides/releases.md index 141a264d5123ab..68f4d0b8bacc6f 100644 --- a/doc/guides/releases.md +++ b/doc/guides/releases.md @@ -25,13 +25,15 @@ official release builds for Node.js, hosted on . * [10. Test the Build](#10-test-the-build) * [11. Tag and Sign the Release Commit](#11-tag-and-sign-the-release-commit) * [12. Set Up For the Next Release](#12-set-up-for-the-next-release) - * [13. Promote and Sign the Release Builds](#13-promote-and-sign-the-release-builds) - * [14. Check the Release](#14-check-the-release) - * [15. Create a Blog Post](#15-create-a-blog-post) - * [16. Create the release on GitHub](#16-create-the-release-on-github) - * [17. Cleanup](#17-cleanup) - * [18. Announce](#18-announce) - * [19. Celebrate](#19-celebrate) + * [13. Cherry-pick the Release Commit to `master`](#13-cherry-pick-the-release-commit-to-master) + * [14. Push the release tag](#14-push-the-release-tag) + * [15. Promote and Sign the Release Builds](#15-promote-and-sign-the-release-builds) + * [16. Check the Release](#16-check-the-release) + * [17. Create a Blog Post](#17-create-a-blog-post) + * [18. Create the release on GitHub](#18-create-the-release-on-github) + * [19. Cleanup](#19-cleanup) + * [20. Announce](#20-announce) + * [21. Celebrate](#21-celebrate) * [LTS Releases](#lts-releases) * [Major Releases](#major-releases) @@ -528,15 +530,31 @@ $ git rebase v1.x $ git push upstream v1.x-staging ``` -Cherry-pick the release commit to `master`. After cherry-picking, edit -`src/node_version.h` to ensure the version macros contain whatever values were -previously on `master`. `NODE_VERSION_IS_RELEASE` should be `0`. **Do not** -cherry-pick the "Working on vx.y.z" commit to `master`. +### 13. Cherry-pick the Release Commit to `master` -Run `make lint` before pushing to `master`, to make sure the Changelog -formatting passes the lint rules on `master`. +```console +$ git checkout master +$ git cherry-pick v1.x^ +``` + +Git should stop to let you fix conflicts. Revert all changes that were made to +`src/node_version.h`. If there are conflicts in `doc` due to updated `REPLACEME` +placeholders (that happens when a change previously landed on another release +branch), keep both version numbers. Convert the YAML field to an array if it is +not already one. + +Then finish cherry-picking and push the commit upstream: + +```console +$ git add src/node_version.h doc +$ git cherry-pick --continue +$ make lint +$ git push upstream master +``` + +**Do not** cherry-pick the "Working on vx.y.z" commit to `master`. -### 13. Push the release tag +### 14. Push the release tag Push the tag to the repo before you promote the builds. If you haven't pushed your tag first, then build promotion won't work properly. Push the tag using the @@ -549,7 +567,7 @@ $ git push *Note*: Please do not push the tag unless you are ready to complete the remainder of the release steps. -### 14. Promote and Sign the Release Builds +### 15. Promote and Sign the Release Builds **The same individual who signed the release tag must be the one to promote the builds as the `SHASUMS256.txt` file needs to be signed with the @@ -622,7 +640,7 @@ be prompted to re-sign `SHASUMS256.txt`. **It is possible to only sign a release by running `./tools/release.sh -s vX.Y.Z`.** -### 15. Check the Release +### 16. Check the Release Your release should be available at `https://nodejs.org/dist/vx.y.z/` and . Check that the appropriate files are in @@ -631,7 +649,7 @@ have the right internal version strings. Check that the API docs are available at . Check that the release catalog files are correct at and . -### 16. Create a Blog Post +### 17. Create a Blog Post There is an automatic build that is kicked off when you promote new builds, so within a few minutes nodejs.org will be listing your new version as the latest @@ -664,7 +682,7 @@ This script will use the promoted builds and changelog to generate the post. Run * Changes to `master` on the [nodejs.org repository][] will trigger a new build of nodejs.org so your changes should appear a few minutes after pushing. -### 17. Create the release on GitHub +### 18. Create the release on GitHub * Go to the [New release page](https://github.com/nodejs/node/releases/new). * Select the tag version you pushed earlier. @@ -672,11 +690,11 @@ This script will use the promoted builds and changelog to generate the post. Run * For the description, copy the rest of the changelog entry. * Click on the "Publish release" button. -### 18. Cleanup +### 19. Cleanup Close your release proposal PR and delete the proposal branch. -### 19. Announce +### 20. Announce The nodejs.org website will automatically rebuild and include the new version. To announce the build on Twitter through the official @nodejs account, email @@ -693,7 +711,7 @@ announcements. Ping the IRC ops and the other [Partner Communities][] liaisons. -### 20. Celebrate +### 21. Celebrate _In whatever form you do this..._ From 2439071e18dd625d0f91bd2be3eb8b7fc6894eaf Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Tue, 21 Apr 2020 23:35:48 -0400 Subject: [PATCH 19/20] module: refactor condition PR-URL: https://github.com/nodejs/node/pull/32989 Reviewed-By: Zeyu Yang Reviewed-By: Colin Ihrig Reviewed-By: Andrey Pechkurov --- lib/internal/errors.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/internal/errors.js b/lib/internal/errors.js index aa15de1fb507e5..3f31bdc330d2fe 100644 --- a/lib/internal/errors.js +++ b/lib/internal/errors.js @@ -1121,8 +1121,7 @@ E('ERR_INVALID_PACKAGE_TARGET', return `Invalid "exports" main target ${JSONStringify(target)} defined ` + `in the package config ${pkgPath}${sep}package.json${relError ? '; targets must start with "./"' : ''}`; - } else if (typeof target === 'string' && target !== '' && - !StringPrototypeStartsWith(target, './')) { + } else if (relError) { return `Invalid "exports" target ${JSONStringify(target)} defined for '${ StringPrototypeSlice(key, 0, -subpath.length || key.length)}' in the ` + `package config ${pkgPath}${sep}package.json; ` + From 684a81d023dc4071c31b994f0447d3401af228f8 Mon Sep 17 00:00:00 2001 From: Sam Roberts Date: Tue, 21 Apr 2020 10:39:39 -0700 Subject: [PATCH 20/20] doc: make openssl maintenance position independent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It used to have some `cd` commands that if done literally would invalidate the subsequent commands. Modify them to be more accurate, which also simplifies pasting them directly into the console from the guide while doing an update. PR-URL: https://github.com/nodejs/node/pull/32977 Reviewed-By: Richard Lau Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Gerhard Stöbich --- doc/guides/maintaining-openssl.md | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/doc/guides/maintaining-openssl.md b/doc/guides/maintaining-openssl.md index 5bfe01e0f61b56..af59486b0f3219 100644 --- a/doc/guides/maintaining-openssl.md +++ b/doc/guides/maintaining-openssl.md @@ -57,7 +57,7 @@ This updates all sources in deps/openssl/openssl by: Use `make` to regenerate all platform dependent files in `deps/openssl/config/archs/`: ```sh -% cd deps/openssl/config; make +% make -C deps/openssl/config ``` ## 3. Check diffs @@ -66,8 +66,7 @@ Check diffs if updates are right. Even if no updates in openssl sources, `buildinf.h` files will be updated for they have a timestamp data in them. ```sh -% cd deps/openssl/config -% git diff +% git diff -- deps/openssl ``` *Note*: On Windows, OpenSSL Configure generates `makefile` that can be @@ -95,8 +94,7 @@ The commit message can be (with the openssl version set to the relevant value): After an OpenSSL source update, all the config files need to be regenerated and committed by: - $ cd deps/openssl/config - $ make + $ make -C deps/openssl/config $ git add deps/openssl/config/archs $ git add deps/openssl/openssl/include/crypto/bn_conf.h $ git add deps/openssl/openssl/include/crypto/dso_conf.h