From 60c81c08a965f5de6e453f37d1dce373fb767633 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Wed, 21 Jun 2017 20:24:31 +0200 Subject: [PATCH 01/33] v8: add new to the throw statement PR-URL: https://github.com/nodejs/node/pull/13857 Reviewed-By: Refael Ackermann Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Michael Dawson --- lib/v8.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/v8.js b/lib/v8.js index ba95c98dadc1ee..fccc39edc6833f 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -154,7 +154,7 @@ class DefaultSerializer extends Serializer { i = arrayBufferViewTypeToIndex.get(tag); if (i === undefined) { - throw this._getDataCloneError(`Unknown host object type: ${tag}`); + throw new this._getDataCloneError(`Unknown host object type: ${tag}`); } } this.writeUint32(i); From f56a4ba11a0181e93e196e56aadd0ac8a33aec1b Mon Sep 17 00:00:00 2001 From: Robert Rossmann Date: Mon, 25 Sep 2017 11:28:00 +0200 Subject: [PATCH 02/33] process: Send signal name to signal handlers PR-URL: https://github.com/nodejs/node/pull/15606 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Ben Noordhuis Reviewed-By: Evan Lucas Reviewed-By: Gireesh Punathil Reviewed-By: Bartosz Sosnowski --- doc/api/process.md | 11 +++++++++++ lib/internal/process.js | 2 +- test/parallel/test-signal-args.js | 24 ++++++++++++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 test/parallel/test-signal-args.js diff --git a/doc/api/process.md b/doc/api/process.md index 574fc933671d14..74d9fb0cc1532e 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -349,6 +349,9 @@ Signal events will be emitted when the Node.js process receives a signal. Please refer to signal(7) for a listing of standard POSIX signal names such as `SIGINT`, `SIGHUP`, etc. +The signal handler will receive the signal's name (`'SIGINT'`, + `'SIGTERM'`, etc.) as the first argument. + The name of each event will be the uppercase common name for the signal (e.g. `'SIGINT'` for `SIGINT` signals). @@ -361,6 +364,14 @@ process.stdin.resume(); process.on('SIGINT', () => { console.log('Received SIGINT. Press Control-D to exit.'); }); + +// Using a single function to handle multiple signals +function handle(signal) { + console.log(`Received ${signal}`); +} + +process.on('SIGINT', handle); +process.on('SIGTERM', handle); ``` * `SIGUSR1` is reserved by Node.js to start the [debugger][]. It's possible to diff --git a/lib/internal/process.js b/lib/internal/process.js index 4573b9429ed0cd..1d1ed5cd977f51 100644 --- a/lib/internal/process.js +++ b/lib/internal/process.js @@ -201,7 +201,7 @@ function setupSignalHandlers() { wrap.unref(); - wrap.onsignal = function() { process.emit(type); }; + wrap.onsignal = function() { process.emit(type, type); }; const signum = constants[type]; const err = wrap.start(signum); diff --git a/test/parallel/test-signal-args.js b/test/parallel/test-signal-args.js new file mode 100644 index 00000000000000..d9fa6df347ddaa --- /dev/null +++ b/test/parallel/test-signal-args.js @@ -0,0 +1,24 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); + +if (common.isWindows) { + common.skip('Sending signals with process.kill is not supported on Windows'); +} + +process.once('SIGINT', common.mustCall((signal) => { + assert.strictEqual(signal, 'SIGINT'); +})); + +process.kill(process.pid, 'SIGINT'); + +process.once('SIGTERM', common.mustCall((signal) => { + assert.strictEqual(signal, 'SIGTERM'); +})); + +process.kill(process.pid, 'SIGTERM'); + +// Prevent Node.js from exiting due to empty event loop before signal handlers +// are fired +setImmediate(() => {}); From 08ccba786cb83e2c7af928ea129361f6146ba30c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=88=9A?= Date: Mon, 22 Jan 2018 00:58:35 +0800 Subject: [PATCH 03/33] doc: `readable.push(undefined)` in non-object mode `readable.push()` supports `undefined` in non-object mode, but it was not previously documented. PR-URL: https://github.com/nodejs/node/pull/18283 Reviewed-By: James M Snell Reviewed-By: Matteo Collina --- doc/api/stream.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/api/stream.md b/doc/api/stream.md index f0d393543d6516..b312e0f483f06d 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -1740,6 +1740,10 @@ class SourceWrapper extends Readable { *Note*: The `readable.push()` method is intended be called only by Readable Implementers, and only from within the `readable._read()` method. +For streams not operating in object mode, if the `chunk` parameter of +`readable.push()` is `undefined`, it will be treated as empty string or +buffer. See [`readable.push('')`][] for more information. + #### Errors While Reading It is recommended that errors occurring during the processing of the @@ -2259,6 +2263,7 @@ contain multi-byte characters. [`stream.uncork()`]: #stream_writable_uncork [`stream.unpipe()`]: #stream_readable_unpipe_destination [`stream.wrap()`]: #stream_readable_wrap_stream +[`readable.push('')`]: #stream_readable_push [`writable.cork()`]: #stream_writable_cork [`writable.uncork()`]: #stream_writable_uncork [`zlib.createDeflate()`]: zlib.html#zlib_zlib_createdeflate_options From 88adf767ba37355c97b797ebfd670ed1d6842fe9 Mon Sep 17 00:00:00 2001 From: flickz Date: Sun, 11 Feb 2018 20:21:09 +0100 Subject: [PATCH 04/33] doc: add process.debugPort to doc/api/process.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: https://github.com/nodejs/node/issues/18639 PR-URL: https://github.com/nodejs/node/pull/18716 Refs: https://github.com/nodejs/node/issues/18639 Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Matheus Marchini Reviewed-By: Benjamin Gruenbaum Reviewed-By: Tobias Nießen --- doc/api/process.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/api/process.md b/doc/api/process.md index 74d9fb0cc1532e..a56bd36b5a2931 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -631,7 +631,17 @@ process. ```js console.log(`Current directory: ${process.cwd()}`); ``` +## process.debugPort + +* {number} +The port used by Node.js's debugger when enabled. + +```js +process.debugPort = 5858; +``` ## process.disconnect() From 7f7e9935c29d0fa4046faf5a690e768cc6dc473b Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Sat, 3 Mar 2018 19:05:12 +0100 Subject: [PATCH 18/33] test: move require http2 to after crypto check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently test-http2-client-write-empty-string.js will throw "Error [ERR_NO_CRYPTO]: Node.js is not compiled with OpenSSL crypto support" when configured --without-ssl. This commit moves the require of http2 to after the crypto check to avoid this error. PR-URL: https://github.com/nodejs/node/pull/19111 Reviewed-By: Anatoli Papirovski Reviewed-By: Colin Ihrig Reviewed-By: Luigi Pinca Reviewed-By: Rich Trott Reviewed-By: Tobias Nießen Reviewed-By: James M Snell Reviewed-By: Jon Moss --- test/parallel/test-http2-client-write-empty-string.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/parallel/test-http2-client-write-empty-string.js b/test/parallel/test-http2-client-write-empty-string.js index c10698d417038d..8b8cb3d6404e1e 100644 --- a/test/parallel/test-http2-client-write-empty-string.js +++ b/test/parallel/test-http2-client-write-empty-string.js @@ -1,12 +1,13 @@ 'use strict'; const assert = require('assert'); -const http2 = require('http2'); const common = require('../common'); if (!common.hasCrypto) common.skip('missing crypto'); +const http2 = require('http2'); + for (const chunkSequence of [ [ '' ], [ '', '' ] From 85d8d225e6881fafa31314dabff486c821a532b7 Mon Sep 17 00:00:00 2001 From: "Steven R. Loomis" Date: Mon, 5 Mar 2018 12:14:58 -0800 Subject: [PATCH 19/33] src: #include " to iculslocs iculslocs uses stdio, but didn't include the header. PR-URL: https://github.com/nodejs/node/pull/19150 Reviewed-By: Richard Lau Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Gireesh Punathil --- tools/icu/iculslocs.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/icu/iculslocs.cc b/tools/icu/iculslocs.cc index 3ceb8d2a4d81d0..a6931d3a9a62d6 100644 --- a/tools/icu/iculslocs.cc +++ b/tools/icu/iculslocs.cc @@ -55,6 +55,7 @@ Japanese, it doesn't *claim* to have Japanese. #include #include #include +#include const char* PROG = "iculslocs"; const char* NAME = U_ICUDATA_NAME; // assume ICU data From 2ae1048aef84049609ff67eb2103b5ea9ec30087 Mon Sep 17 00:00:00 2001 From: Timothy Gu Date: Sun, 25 Feb 2018 14:26:22 -0800 Subject: [PATCH 20/33] perf_hooks: fix timing Fixes: https://github.com/nodejs/node/issues/17892 Fixes: https://github.com/nodejs/node/issues/17893 Fixes: https://github.com/nodejs/node/issues/18992 PR-URL: https://github.com/nodejs/node/pull/18993 Reviewed-By: James M Snell Reviewed-By: Anna Henningsen Reviewed-By: Colin Ihrig Reviewed-By: Anatoli Papirovski --- doc/api/perf_hooks.md | 31 +++++---- lib/perf_hooks.js | 52 +++++++++------ src/node_perf.cc | 35 ++++++++++ src/node_perf.h | 8 ++- src/node_perf_common.h | 6 +- test/parallel/test-performance.js | 102 ++++++++++++++++++++++++------ 6 files changed, 182 insertions(+), 52 deletions(-) diff --git a/doc/api/perf_hooks.md b/doc/api/perf_hooks.md index c1ca15718dc5d4..4a1eeaf98199ec 100644 --- a/doc/api/perf_hooks.md +++ b/doc/api/perf_hooks.md @@ -181,7 +181,8 @@ added: v8.5.0 * Returns: {number} -Returns the current high resolution millisecond timestamp. +Returns the current high resolution millisecond timestamp, where 0 represents +the start of the current `node` process. ### performance.timeOrigin