From f3f19ee5e23801a0b9f1cd678f3ffe0de9eb759a Mon Sep 17 00:00:00 2001 From: Benjamin Gruenbaum Date: Wed, 23 Mar 2016 10:14:29 +0200 Subject: [PATCH 01/30] net: refactor self=this to arrow functions Refactor unused self=this code to code without without this pattern making it more consistent with the rest of our code. PR-URL: https://github.com/nodejs/node/pull/5857 Reviewed-By: Brian White Reviewed-By: Colin Ihrig Reviewed-By: Jeremiah Senkpiel Reviewed-By: Roman Klauke --- lib/net.js | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/lib/net.js b/lib/net.js index 6731380d002b6b..f93691c3fbce94 100644 --- a/lib/net.js +++ b/lib/net.js @@ -444,9 +444,7 @@ Socket.prototype.destroySoon = function() { Socket.prototype._destroy = function(exception, cb) { debug('destroy'); - var self = this; - - function fireErrorCallbacks() { + function fireErrorCallbacks(self) { if (cb) cb(exception); if (exception && !self._writableState.errorEmitted) { process.nextTick(emitErrorNT, self, exception); @@ -456,11 +454,11 @@ Socket.prototype._destroy = function(exception, cb) { if (this.destroyed) { debug('already destroyed, fire error callbacks'); - fireErrorCallbacks(); + fireErrorCallbacks(this); return; } - self._connecting = false; + this._connecting = false; this.readable = this.writable = false; @@ -472,9 +470,9 @@ Socket.prototype._destroy = function(exception, cb) { if (this !== process.stderr) debug('close handle'); var isException = exception ? true : false; - this._handle.close(function() { + this._handle.close(() => { debug('emit close'); - self.emit('close', isException); + this.emit('close', isException); }); this._handle.onread = noop; this._handle = null; @@ -485,7 +483,7 @@ Socket.prototype._destroy = function(exception, cb) { // to make it re-entrance safe in case Socket.prototype.destroy() // is called within callbacks this.destroyed = true; - fireErrorCallbacks(); + fireErrorCallbacks(this); if (this._server) { COUNTER_NET_SERVER_CONNECTION_CLOSE(this); @@ -1078,33 +1076,31 @@ function Server(options, connectionListener) { EventEmitter.call(this); - var self = this; - if (typeof options === 'function') { connectionListener = options; options = {}; - self.on('connection', connectionListener); + this.on('connection', connectionListener); } else { options = options || {}; if (typeof connectionListener === 'function') { - self.on('connection', connectionListener); + this.on('connection', connectionListener); } } this._connections = 0; Object.defineProperty(this, 'connections', { - get: internalUtil.deprecate(function() { + get: internalUtil.deprecate(() => { - if (self._usingSlaves) { + if (this._usingSlaves) { return null; } - return self._connections; + return this._connections; }, 'Server.connections property is deprecated. ' + 'Use Server.getConnections method instead.'), - set: internalUtil.deprecate(function(val) { - return (self._connections = val); + set: internalUtil.deprecate((val) => { + return (this._connections = val); }, 'Server.connections property is deprecated.'), configurable: true, enumerable: false }); From 0a13099c420b228137acec4146483a82e4cdf657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Reis?= Date: Mon, 21 Mar 2016 17:36:54 +0000 Subject: [PATCH 02/30] etw: add event messages Reviewed-By: Ben Noordhuis PR-URL: https://github.com/nodejs/node/pull/5936 --- src/res/node_etw_provider.man | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/res/node_etw_provider.man b/src/res/node_etw_provider.man index efdc26d3dee722..46ad2e38fccad7 100644 --- a/src/res/node_etw_provider.man +++ b/src/res/node_etw_provider.man @@ -7,6 +7,7 @@ @@ -90,64 +91,95 @@ opcode="NODE_HTTP_SERVER_REQUEST" template="node_http_server_request" symbol="NODE_HTTP_SERVER_REQUEST_EVENT" + message="$(string.NodeJS-ETW-provider.event.1.message)" level="win:Informational"/> + + + + + + + + + + + + + + + + + + + From f14d71ccea6b9bfb63e2ac2fc2004a904e511466 Mon Sep 17 00:00:00 2001 From: Jeremiah Senkpiel Date: Mon, 28 Mar 2016 11:24:34 -0400 Subject: [PATCH 03/30] test: stdin is not always a net.Socket `<`-ing a file into stdin actually results in a `fs.ReadStream`, rather than a `tty.ReadStream`, and as such does not inherit from net.Socket, unlike the other possible stdin options. Refs: https://github.com/nodejs/node/pull/5916 PR-URL: https://github.com/nodejs/node/pull/5935 Reviewed-By: Colin Ihrig --- .../test-stdin-is-always-net.socket.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/known_issues/test-stdin-is-always-net.socket.js diff --git a/test/known_issues/test-stdin-is-always-net.socket.js b/test/known_issues/test-stdin-is-always-net.socket.js new file mode 100644 index 00000000000000..a0c5c63198dbde --- /dev/null +++ b/test/known_issues/test-stdin-is-always-net.socket.js @@ -0,0 +1,19 @@ +'use strict'; +// Refs: https://github.com/nodejs/node/pull/5916 + +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; +const net = require('net'); + +if (process.argv[2] === 'child') { + assert(process.stdin instanceof net.Socket); + return; +} + +const proc = spawn(process.execPath, [__filename, 'child'], { stdio: 'ignore' }); +// To double-check this test, set stdio to 'pipe' and uncomment the line below. +// proc.stderr.pipe(process.stderr); +proc.on('exit', common.mustCall(function(exitCode) { + process.exitCode = exitCode; +})); From 4f1fa2adeb0fd93616cc9ed6d164196020bd33ee Mon Sep 17 00:00:00 2001 From: Sakthipriyan Vairamani Date: Fri, 1 Apr 2016 02:28:39 +0530 Subject: [PATCH 04/30] test: fix offending max-len linter error Refer: https://github.com/nodejs/node/pull/5935 PR-URL: https://github.com/nodejs/node/pull/5980 Reviewed-By: Jeremiah Senkpiel Reviewed-By: Phillip Johnsen --- test/known_issues/test-stdin-is-always-net.socket.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/known_issues/test-stdin-is-always-net.socket.js b/test/known_issues/test-stdin-is-always-net.socket.js index a0c5c63198dbde..78c1a7d2eac20e 100644 --- a/test/known_issues/test-stdin-is-always-net.socket.js +++ b/test/known_issues/test-stdin-is-always-net.socket.js @@ -11,7 +11,7 @@ if (process.argv[2] === 'child') { return; } -const proc = spawn(process.execPath, [__filename, 'child'], { stdio: 'ignore' }); +const proc = spawn(process.execPath, [__filename, 'child'], {stdio: 'ignore'}); // To double-check this test, set stdio to 'pipe' and uncomment the line below. // proc.stderr.pipe(process.stderr); proc.on('exit', common.mustCall(function(exitCode) { From 96bb3152629c56f1a158e9fdf586c294ff2991ba Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 26 Mar 2016 15:26:15 -0700 Subject: [PATCH 05/30] test: ensure _handle property existence `test-stdtout-close-unref.js` will fail if `process.stdin._handle` does not exist. On UNIX-like operating systems, you can see this failure this way: ./node test/parallel/test-stdout-close-unref.js < /dev/null This issue has been experienced by @bengl and @drewfish in a Docker container. I'm not sure why they are experiencing it in their environment, but since it is possible that the `_handle` property does not exist, let's use `child_process.spawn()` to make sure it exists. PR-URL: https://github.com/nodejs/node/pull/5916 Reviewed-By: Jeremiah Senkpiel --- test/parallel/test-stdout-close-unref.js | 38 ++++++++++++++++-------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-stdout-close-unref.js b/test/parallel/test-stdout-close-unref.js index 37ab4987eebcaa..67c6141c963088 100644 --- a/test/parallel/test-stdout-close-unref.js +++ b/test/parallel/test-stdout-close-unref.js @@ -1,16 +1,30 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; -var errs = 0; +if (process.argv[2] === 'child') { + var errs = 0; -process.stdin.resume(); -process.stdin._handle.close(); -process.stdin._handle.unref(); // Should not segfault. -process.stdin.on('error', function(err) { - errs++; -}); + process.stdin.resume(); + process.stdin._handle.close(); + process.stdin._handle.unref(); // Should not segfault. + process.stdin.on('error', function(err) { + errs++; + }); -process.on('exit', function() { - assert.strictEqual(errs, 1); -}); + process.on('exit', function() { + assert.strictEqual(errs, 1); + }); + return; +} + +// Use spawn so that we can be sure that stdin has a _handle property. +// Refs: https://github.com/nodejs/node/pull/5916 +const proc = spawn(process.execPath, [__filename, 'child'], { stdio: 'pipe' }); + +proc.stderr.pipe(process.stderr); +proc.on('exit', common.mustCall(function(exitCode) { + if (exitCode !== 0) + process.exitCode = exitCode; +})); From c6ac6f2ea1480623d2c654db65ee7445041f635d Mon Sep 17 00:00:00 2001 From: Mihai Potra Date: Fri, 19 Feb 2016 10:21:49 +0200 Subject: [PATCH 06/30] http: Corrects IPv6 address in Host header IPv6 addresses in Host header (URI), must be enclosed within square brackets, in order to properly separate the host address from any port reference. PR-URL: https://github.com/nodejs/node/pull/5314 Reviewed-By: James M Snell Reviewed-By: Evan Lucas --- lib/_http_client.js | 11 +++++ .../test-http-host-header-ipv6-fail.js | 40 +++++++++++++++++++ 2 files changed, 51 insertions(+) create mode 100644 test/parallel/test-http-host-header-ipv6-fail.js diff --git a/lib/_http_client.js b/lib/_http_client.js index cd4ce0e9cd3426..e051ebe5fdb01c 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -87,6 +87,17 @@ function ClientRequest(options, cb) { } if (host && !this.getHeader('host') && setHost) { var hostHeader = host; + var posColon = -1; + + // For the Host header, ensure that IPv6 addresses are enclosed + // in square brackets, as defined by URI formatting + // https://tools.ietf.org/html/rfc3986#section-3.2.2 + if (-1 !== (posColon = hostHeader.indexOf(':')) && + -1 !== (posColon = hostHeader.indexOf(':', posColon)) && + '[' !== hostHeader[0]) { + hostHeader = `[${hostHeader}]`; + } + if (port && +port !== defaultPort) { hostHeader += ':' + port; } diff --git a/test/parallel/test-http-host-header-ipv6-fail.js b/test/parallel/test-http-host-header-ipv6-fail.js new file mode 100644 index 00000000000000..8a1a9a61afe5af --- /dev/null +++ b/test/parallel/test-http-host-header-ipv6-fail.js @@ -0,0 +1,40 @@ +'use strict'; +/* + * When using the object form of http.request and using an IPv6 address + * as a hostname, and using a non-standard port, the Host header + * is improperly formatted. + * Issue: https://github.com/nodejs/node/issues/5308 + * As per https://tools.ietf.org/html/rfc7230#section-5.4 and + * https://tools.ietf.org/html/rfc3986#section-3.2.2 + * the IPv6 address should be enclosed in square brackets + */ + +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); + +const hostname = '::1'; +const port = common.PORT; + +function httpreq() { + var req = http.request({ + host: hostname, + port: port, + path: '/', + method: 'GET' + }); + req.end(); +} + +if (!common.hasIPv6) { + console.error('Skipping test, no IPv6 support'); + return; +} + +const server = http.createServer(common.mustCall(function(req, res) { + assert.ok(req.headers.host, `[${hostname}]`); + res.end(); + server.close(true); +})); + +server.listen(port, hostname, () => httpreq()); From 3f75751c2ef8ff85970ecdb28f2e0272dddcb5b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20Bergstr=C3=B6m?= Date: Sun, 27 Mar 2016 17:12:47 +1100 Subject: [PATCH 07/30] build: introduce ci targets for lint/benchmark MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce two new targets we will populate with actions once merged into all branches we need to support through CI. PR-URL: https://github.com/nodejs/node/pull/5921 Reviewed-By: Brian White Reviewed-By: Myles Borins Reviewed-By: João Reis Reviewed-By: James M Snell --- Makefile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 93aedc8c2722f1..b4edaee1bf29ba 100644 --- a/Makefile +++ b/Makefile @@ -581,6 +581,8 @@ bench-all: bench bench-misc bench-array bench-buffer bench-url bench-events benc bench: bench-net bench-http bench-fs bench-tls +bench-ci: bench + bench-http-simple: benchmark/http_simple_bench.sh @@ -620,10 +622,12 @@ cpplint: lint: jslint cpplint +lint-ci: lint + .PHONY: lint cpplint jslint bench clean docopen docclean doc dist distclean \ check uninstall install install-includes install-bin all staticlib \ dynamiclib test test-all test-addons build-addons website-upload pkg \ blog blogclean tar binary release-only bench-http-simple bench-idle \ bench-all bench bench-misc bench-array bench-buffer bench-net \ bench-http bench-fs bench-tls cctest run-ci test-v8 test-v8-intl \ - test-v8-benchmarks test-v8-all v8 + test-v8-benchmarks test-v8-all v8 lint-ci bench-ci From a40b0cb673e68ec251d647ee774522aba99f885b Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Sat, 12 Mar 2016 17:25:08 +0100 Subject: [PATCH 08/30] test: refactor http-end-throw-socket-handling Remove timer to avoid the test timing out occasionally. PR-URL: https://github.com/nodejs/node/pull/5676 Reviewed-By: James M Snell Reviewed-By: Claudio Rodriguez --- .../test-http-end-throw-socket-handling.js | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/test/parallel/test-http-end-throw-socket-handling.js b/test/parallel/test-http-end-throw-socket-handling.js index 204c0f73335480..d6cc81d98a8fb9 100644 --- a/test/parallel/test-http-end-throw-socket-handling.js +++ b/test/parallel/test-http-end-throw-socket-handling.js @@ -1,6 +1,6 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); // Make sure that throwing in 'end' handler doesn't lock // up the socket forever. @@ -8,40 +8,32 @@ var assert = require('assert'); // This is NOT a good way to handle errors in general, but all // the same, we should not be so brittle and easily broken. -var http = require('http'); +const http = require('http'); -var n = 0; -var server = http.createServer(function(req, res) { +let n = 0; +const server = http.createServer((req, res) => { if (++n === 10) server.close(); res.end('ok'); }); -server.listen(common.PORT, function() { - for (var i = 0; i < 10; i++) { - var options = { port: common.PORT }; - - var req = http.request(options, function(res) { +server.listen(common.PORT, common.mustCall(() => { + for (let i = 0; i < 10; i++) { + const options = { port: common.PORT }; + const req = http.request(options, (res) => { res.resume(); - res.on('end', function() { + res.on('end', common.mustCall(() => { throw new Error('gleep glorp'); - }); + })); }); req.end(); } -}); +})); -setTimeout(function() { - process.removeListener('uncaughtException', catcher); - throw new Error('Taking too long!'); -}, common.platformTimeout(1000)).unref(); - -process.on('uncaughtException', catcher); -var errors = 0; -function catcher() { +let errors = 0; +process.on('uncaughtException', () => { errors++; -} +}); -process.on('exit', function() { +process.on('exit', () => { assert.equal(errors, 10); - console.log('ok'); }); From 8bec8aa41ff7f9fc0a241db2df1921fab7a5587e Mon Sep 17 00:00:00 2001 From: Bryan English Date: Mon, 21 Mar 2016 16:03:41 -0700 Subject: [PATCH 09/30] doc: consolidate timers docs in timers.markdown Rather than attempting to keep two versions of docs for timers up to date, keep them in timers.markdown, and leave references to them in globals.markdown. Add setImmediate and clearImmediate to globals.markdown. Change "To schedule" to "Schedules" in timers.markdown. PR-URL: https://github.com/nodejs/node/pull/5837 Reviewed-By: Benjamin Gruenbaum Reviewed-By: Jeremiah Senkpiel Reviewed-By: Claudio Rodriguez Reviewed-By: Sakthipriyan Vairamani --- doc/api/globals.markdown | 51 +++++++++++++++++++++------------------- doc/api/timers.markdown | 6 ++--- 2 files changed, 30 insertions(+), 27 deletions(-) diff --git a/doc/api/globals.markdown b/doc/api/globals.markdown index 9ee5e48983730a..94fc332f94ac32 100644 --- a/doc/api/globals.markdown +++ b/doc/api/globals.markdown @@ -50,19 +50,23 @@ console.log(__filename); `__filename` isn't actually a global but rather local to each module. -## clearInterval(t) +## clearImmediate(immediateObject) -Stop a timer that was previously created with [`setInterval()`][]. The callback -will not execute. + + +[`clearImmediate`] is described in the [timers][] section. + +## clearInterval(intervalObject) -The timer functions are global variables. See the [timers][] section. +[`clearInterval`] is described in the [timers][] section. -## clearTimeout(t) +## clearTimeout(timeoutObject) + + -Stop a timer that was previously created with [`setTimeout()`][]. The callback will -not execute. +[`clearTimeout`] is described in the [timers][] section. ## console @@ -162,34 +166,33 @@ left untouched. Use the internal `require()` machinery to look up the location of a module, but rather than loading the module, just return the resolved filename. -## setInterval(cb, ms) +## setImmediate(callback[, arg][, ...]) -Run callback `cb` repeatedly every `ms` milliseconds. Note that the actual -interval may vary, depending on external factors like OS timer granularity and -system load. It's never less than `ms` but it may be longer. + + +[`setImmediate`] is described in the [timers][] section. -The interval must be in the range of 1-2,147,483,647 inclusive. If the value is -outside that range, it's changed to 1 millisecond. Broadly speaking, a timer -cannot span more than 24.8 days. +## setInterval(callback, delay[, arg][, ...]) -Returns an opaque value that represents the timer. + -## setTimeout(cb, ms) +[`setInterval`] is described in the [timers][] section. -Run callback `cb` after *at least* `ms` milliseconds. The actual delay depends -on external factors like OS timer granularity and system load. +## setTimeout(callback, delay[, arg][, ...]) -The timeout must be in the range of 1-2,147,483,647 inclusive. If the value is -outside that range, it's changed to 1 millisecond. Broadly speaking, a timer -cannot span more than 24.8 days. + -Returns an opaque value that represents the timer. +[`setTimeout`] is described in the [timers][] section. [`console`]: console.html [`process` object]: process.html#process_process -[`setInterval()`]: #globals_setinterval_cb_ms -[`setTimeout()`]: #globals_settimeout_cb_ms [buffer section]: buffer.html [module system documentation]: modules.html [Modules]: modules.html#modules_modules [timers]: timers.html +[`clearImmediate`]: timers.html#timers_clearimmediate_immediateobject +[`clearInterval`]: timers.html#timers_clearinterval_intervalobject +[`clearTimeout`]: timers.html#timers_cleartimeout_timeoutobject +[`setImmediate`]: timers.html#timers_setimmediate_callback_arg +[`setInterval`]: timers.html#timers_setinterval_callback_delay_arg +[`setTimeout`]: timers.html#timers_settimeout_callback_delay_arg diff --git a/doc/api/timers.markdown b/doc/api/timers.markdown index 7859e7fecd6273..3990ab6c1d391d 100644 --- a/doc/api/timers.markdown +++ b/doc/api/timers.markdown @@ -27,7 +27,7 @@ Returns the timer. ## setImmediate(callback[, arg][, ...]) -To schedule the "immediate" execution of `callback` after I/O events' +Schedules "immediate" execution of `callback` after I/O events' callbacks and before timers set by [`setTimeout`][] and [`setInterval`][] are triggered. Returns an `immediateObject` for possible use with [`clearImmediate`][]. Additional optional arguments may be passed to the @@ -40,7 +40,7 @@ until the next event loop iteration. ## setInterval(callback, delay[, arg][, ...]) -To schedule the repeated execution of `callback` every `delay` milliseconds. +Schedules repeated execution of `callback` every `delay` milliseconds. Returns a `intervalObject` for possible use with [`clearInterval`][]. Additional optional arguments may be passed to the callback. @@ -50,7 +50,7 @@ milliseconds (approximately 25 days) or less than 1, Node.js will use 1 as the ## setTimeout(callback, delay[, arg][, ...]) -To schedule execution of a one-time `callback` after `delay` milliseconds. +Schedules execution of a one-time `callback` after `delay` milliseconds. Returns a `timeoutObject` for possible use with [`clearTimeout`][]. Additional optional arguments may be passed to the callback. From 0ae5d027c676182e4e3c6745e05e5ff240ee3987 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 1 Apr 2016 23:06:28 -0700 Subject: [PATCH 10/30] doc: clarify that __dirname is module local Fixes: https://github.com/nodejs/node/issues/5525 PR-URL: https://github.com/nodejs/node/pull/6018 Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Roman Klauke Reviewed-By: Colin Ihrig --- doc/api/globals.markdown | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/api/globals.markdown b/doc/api/globals.markdown index 94fc332f94ac32..1bee7d0cf988c2 100644 --- a/doc/api/globals.markdown +++ b/doc/api/globals.markdown @@ -30,6 +30,16 @@ console.log(__dirname); `__dirname` isn't actually a global but rather local to each module. +For instance, given two modules: `a` and `b`, where `b` is a dependency of +`a` and there is a directory structure of: + +* `/Users/mjr/app/a.js` +* `/Users/mjr/app/node_modules/b/b.js` + +References to `__dirname` within `b.js` will return +`/Users/mjr/app/node_modules/b` while references to `__dirname` within `a.js` +will return `/Users/mj/app`. + ## \_\_filename From 7337ef6422251264b59f19bbc1743aeb2035621c Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 1 Apr 2016 22:41:14 -0700 Subject: [PATCH 11/30] doc: minor argument formatting in stream.markdown Fixes: https://github.com/nodejs/node/issues/4350 PR-URL: https://github.com/nodejs/node/pull/6016 Reviewed-By: Rich Trott Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Roman Klauke Reviewed-By: Colin Ihrig --- doc/api/stream.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/stream.markdown b/doc/api/stream.markdown index cdab6e82ab2cdc..d2d0c4487ed9bf 100644 --- a/doc/api/stream.markdown +++ b/doc/api/stream.markdown @@ -201,7 +201,7 @@ readable.on('end', () => { #### Event: 'error' -* {Error Object} +* {Error} Emitted if there was an error receiving data. From 7491fdcfe93f3f8e86ef57fa00729860144019b4 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 1 Apr 2016 21:52:55 -0700 Subject: [PATCH 12/30] tools: remove disabling of already-disabled rule `require-buffer` is only enabled in the `lib` directory. There is no need to disable it in `test`. PR-URL: https://github.com/nodejs/node/pull/6013 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- test/.eslintrc | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/.eslintrc b/test/.eslintrc index 5d77a660f88762..68b358740f5e3e 100644 --- a/test/.eslintrc +++ b/test/.eslintrc @@ -3,8 +3,6 @@ rules: ## allow undeclared variables no-undef: 0 - ## allow global Buffer usage - require-buffer: 0 ## common module is mandatory in tests required-modules: [2, "common"] From ce173716be246301a23bf95a5f190fe066335725 Mon Sep 17 00:00:00 2001 From: firedfox Date: Sat, 2 Apr 2016 11:15:07 +0800 Subject: [PATCH 13/30] doc: add 'Command Line Options' to 'View on single page' Includes cli.markdown in all.markdown PR-URL: https://github.com/nodejs/node/pull/6011 Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Jeremiah Senkpiel --- doc/api/all.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/api/all.markdown b/doc/api/all.markdown index 8bac0103c88da7..93c7a300a162e9 100644 --- a/doc/api/all.markdown +++ b/doc/api/all.markdown @@ -5,6 +5,7 @@ @include buffer @include child_process @include cluster +@include cli @include console @include crypto @include debugger From f12c3861e09a3c34db02636758f3b9c6e69daf04 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Fri, 1 Apr 2016 22:23:16 -0700 Subject: [PATCH 14/30] doc: clarify stdout/stderr arguments to callback Clarify that the arguments to child_process.execFile and child_process.exec callback can be Buffer or strings. Fixes: https://github.com/nodejs/node/issues/3389 PR-URL: https://github.com/nodejs/node/pull/6015 Reviewed-By: Sakthipriyan Vairamani Reviewed-By: Colin Ihrig --- doc/api/child_process.markdown | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/doc/api/child_process.markdown b/doc/api/child_process.markdown index 5f17b435e6ea87..c4be598ecd9ab2 100644 --- a/doc/api/child_process.markdown +++ b/doc/api/child_process.markdown @@ -131,8 +131,8 @@ exec('my.bat', (err, stdout, stderr) => { * `gid` {Number} Sets the group identity of the process. (See setgid(2).) * `callback` {Function} called with the output when process terminates * `error` {Error} - * `stdout` {Buffer} - * `stderr` {Buffer} + * `stdout` {String|Buffer} + * `stderr` {String|Buffer} * Return: {ChildProcess} Spawns a shell then executes the `command` within that shell, buffering any @@ -157,6 +157,13 @@ the exit code of the child process while `error.signal` will be set to the signal that terminated the process. Any exit code other than `0` is considered to be an error. +The `stdout` and `stderr` arguments passed to the callback will contain the +stdout and stderr output of the child process. By default, Node.js will decode +the output as UTF-8 and pass strings to the callback. The `encoding` option +can be used to specify the character encoding used to decode the stdout and +stderr output. If `encoding` is `'buffer'`, `Buffer` objects will be passed to +the callback instead. + The `options` argument may be passed as the second argument to customize how the process is spawned. The default options are: @@ -198,8 +205,8 @@ replace the existing process and uses a shell to execute the command.* * `gid` {Number} Sets the group identity of the process. (See setgid(2).) * `callback` {Function} called with the output when process terminates * `error` {Error} - * `stdout` {Buffer} - * `stderr` {Buffer} + * `stdout` {String|Buffer} + * `stderr` {String|Buffer} * Return: {ChildProcess} The `child_process.execFile()` function is similar to [`child_process.exec()`][] @@ -220,6 +227,13 @@ const child = execFile('node', ['--version'], (error, stdout, stderr) => { }); ``` +The `stdout` and `stderr` arguments passed to the callback will contain the +stdout and stderr output of the child process. By default, Node.js will decode +the output as UTF-8 and pass strings to the callback. The `encoding` option +can be used to specify the character encoding used to decode the stdout and +stderr output. If `encoding` is `'buffer'`, `Buffer` objects will be passed to +the callback instead. + ### child_process.fork(modulePath[, args][, options]) * `modulePath` {String} The module to run in the child From f879f5e68aa4d1ba25fa5c09200e0115190b54dd Mon Sep 17 00:00:00 2001 From: James M Snell Date: Sun, 27 Mar 2016 08:34:13 -0700 Subject: [PATCH 15/30] doc: document unspecified behavior for buf.write* methods Per https://github.com/nodejs/node/issues/1161, when the buf.write*() methods are given anything other than what they expect, indicate that the behavior is unspecified. Fixes: https://github.com/nodejs/node/issues/1161 PR-URL: https://github.com/nodejs/node/pull/5925 Reviewed-By: Claudio Rodriguez --- doc/api/buffer.markdown | 31 +++++++++++++++++++++---------- 1 file changed, 21 insertions(+), 10 deletions(-) diff --git a/doc/api/buffer.markdown b/doc/api/buffer.markdown index 88891c68a42ac3..a5251fe7ee3be8 100644 --- a/doc/api/buffer.markdown +++ b/doc/api/buffer.markdown @@ -1384,7 +1384,8 @@ console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`); Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeDoubleBE()` writes big endian, `writeDoubleLE()` writes little -endian). The `value` argument must be a valid 64-bit double. +endian). The `value` argument *should* be a valid 64-bit double. Behavior is +not defined when `value` is anything other than a 64-bit double. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1416,7 +1417,7 @@ console.log(buf); Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeFloatBE()` writes big endian, `writeFloatLE()` writes little -endian). Behavior is unspecified if `value` is anything other than a 32-bit +endian). Behavior is not defined when `value` is anything other than a 32-bit float. Set `noAssert` to true to skip validation of `value` and `offset`. This means @@ -1446,8 +1447,9 @@ console.log(buf); * `noAssert` {Boolean} Default: false * Return: {Number} The offset plus the number of written bytes -Writes `value` to the Buffer at the specified `offset`. The `value` must be a -valid signed 8-bit integer. +Writes `value` to the Buffer at the specified `offset`. The `value` should be a +valid signed 8-bit integer. Behavior is not defined when `value` is anything +other than a signed 8-bit integer. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1474,7 +1476,8 @@ console.log(buf); Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeInt16BE()` writes big endian, `writeInt16LE()` writes little -endian). The `value` must be a valid signed 16-bit integer. +endian). The `value` should be a valid signed 16-bit integer. Behavior is +not defined when `value` is anything other than a signed 16-bit integer. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1501,7 +1504,8 @@ console.log(buf); Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeInt32BE()` writes big endian, `writeInt32LE()` writes little -endian). The `value` must be a valid signed 32-bit integer. +endian). The `value` should be a valid signed 32-bit integer. Behavior is +not defined when `value` is anything other than a signed 32-bit integer. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1547,6 +1551,8 @@ that `value` may be too large for the specific function and `offset` may be beyond the end of the Buffer leading to the values being silently dropped. This should not be used unless you are certain of correctness. +Behavior is not defined when `value` is anything other than an integer. + ### buf.writeUInt8(value, offset[, noAssert]) * `value` {Number} Bytes to be written to Buffer @@ -1554,8 +1560,9 @@ should not be used unless you are certain of correctness. * `noAssert` {Boolean} Default: false * Return: {Number} The offset plus the number of written bytes -Writes `value` to the Buffer at the specified `offset`. The `value` must be a -valid unsigned 8-bit integer. +Writes `value` to the Buffer at the specified `offset`. The `value` should be a +valid unsigned 8-bit integer. Behavior is not defined when `value` is anything +other than an unsigned 8-bit integer. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1585,7 +1592,8 @@ console.log(buf); Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeUInt16BE()` writes big endian, `writeUInt16LE()` writes little -endian). The `value` must be a valid unsigned 16-bit integer. +endian). The `value` should be a valid unsigned 16-bit integer. Behavior is +not defined when `value` is anything other than an unsigned 16-bit integer. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1619,7 +1627,8 @@ console.log(buf); Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeUInt32BE()` writes big endian, `writeUInt32LE()` writes little -endian). The `value` must be a valid unsigned 32-bit integer. +endian). The `value` should be a valid unsigned 32-bit integer. Behavior is +not defined when `value` is anything other than an unsigned 32-bit integer. Set `noAssert` to true to skip validation of `value` and `offset`. This means that `value` may be too large for the specific function and `offset` may be @@ -1665,6 +1674,8 @@ that `value` may be too large for the specific function and `offset` may be beyond the end of the Buffer leading to the values being silently dropped. This should not be used unless you are certain of correctness. +Behavior is not defined when `value` is anything other than an unsigned integer. + ## buffer.INSPECT_MAX_BYTES * {Number} Default: 50 From 6052ced37f30c1bcb06856bea08c479376c1755c Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 31 Mar 2016 19:50:29 -0700 Subject: [PATCH 16/30] test: fix error message checks in test-module-loading PR-URL: https://github.com/nodejs/node/pull/5986 Reviewed-By: Colin Ihrig --- test/sequential/test-module-loading.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js index a6f9488f5f8092..d4799691b4e5be 100644 --- a/test/sequential/test-module-loading.js +++ b/test/sequential/test-module-loading.js @@ -252,7 +252,7 @@ assert.throws(function() { assert.throws(function() { console.error('require empty string'); require(''); -}, 'missing path'); +}, /missing path/); process.on('exit', function() { assert.ok(a.A instanceof Function); From 0127c2bd39e835249b038a2d5a4c8bef364647ae Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 1 Apr 2016 06:38:00 -0700 Subject: [PATCH 17/30] test: fix test-dns.js flakiness Use empty string instead of `www.google.com` for tests where we are just doing parameter evaluation. This will avoid DNS lookups which appear to be causing flakiness on Raspberry Pi devices in CI. PR-URL: https://github.com/nodejs/node/pull/5996 Fixes: https://github.com/nodejs/node/issues/5554 Reviewed-By: Michael Dawson Reviewed-By: Colin Ihrig --- test/parallel/test-dns.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index 04264907d308d4..9a2577ec90de78 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var dns = require('dns'); +const dns = require('dns'); var existing = dns.getServers(); assert(existing.length); @@ -121,27 +121,27 @@ assert.doesNotThrow(function() { }); assert.doesNotThrow(function() { - dns.lookup('www.google.com', { + dns.lookup('', { family: 4, hints: 0 }, noop); }); assert.doesNotThrow(function() { - dns.lookup('www.google.com', { + dns.lookup('', { family: 6, hints: dns.ADDRCONFIG }, noop); }); assert.doesNotThrow(function() { - dns.lookup('www.google.com', { + dns.lookup('', { hints: dns.V4MAPPED }, noop); }); assert.doesNotThrow(function() { - dns.lookup('www.google.com', { + dns.lookup('', { hints: dns.ADDRCONFIG | dns.V4MAPPED }, noop); }); From dd25984838f10f566edd9dfe76b4db358a52ef74 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sun, 3 Apr 2016 12:11:10 -0700 Subject: [PATCH 18/30] doc: note assert.throws() pitfall PR-URL: https://github.com/nodejs/node/pull/6029 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- doc/api/assert.markdown | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/api/assert.markdown b/doc/api/assert.markdown index 6bbbf6bd629e22..35dbc3d2192209 100644 --- a/doc/api/assert.markdown +++ b/doc/api/assert.markdown @@ -361,8 +361,13 @@ If the values are not strictly equal, an `AssertionError` is thrown with a ## assert.throws(block[, error][, message]) -Expects the function `block` to throw an error. If specified, `error` can be a -constructor, [`RegExp`][], or validation function. +Expects the function `block` to throw an error. + +If specified, `error` can be a constructor, [`RegExp`][], or validation +function. + +If specified, `message` will be the message provided by the `AssertionError` if +the block fails to throw. Validate instanceof using constructor: @@ -402,6 +407,18 @@ assert.throws( ); ``` +Note that `error` can not be a string. If a string is provided as the second +argument, then `error` is assumed to be omitted and the string will be used for +`message` instead. This can lead to easy-to-miss mistakes: + +```js +// THIS IS A MISTAKE! DO NOT DO THIS! +assert.throws(myFunction, 'missing foo', 'did not throw with expected message'); + +// Do this instead. +assert.throws(myFunction, /missing foo/, 'did not throw with expected message'); +``` + [Locked]: documentation.html#documentation_stability_index [`assert.deepEqual()`]: #assert_assert_deepequal_actual_expected_message [`assert.deepStrictEqual()`]: #assert_assert_deepstrictequal_actual_expected_message From 2ab1237137a98f13214774026a64e6c1e7f4902b Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Mon, 28 Mar 2016 17:07:22 -0700 Subject: [PATCH 19/30] test: fix flaky test-net-socket-timeout-unref Throw immediately on socket timeout rather than checking boolean in exit handler. PR-URL: https://github.com/nodejs/node/pull/6003 Fixes: https://github.com/nodejs/node/issues/5128 Reviewed-By: Myles Borins --- .../parallel/test-net-socket-timeout-unref.js | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/test/parallel/test-net-socket-timeout-unref.js b/test/parallel/test-net-socket-timeout-unref.js index b7ed0ec344a996..bbc2dffcc15336 100644 --- a/test/parallel/test-net-socket-timeout-unref.js +++ b/test/parallel/test-net-socket-timeout-unref.js @@ -1,39 +1,35 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); -var server = net.createServer(function(c) { +// Test that unref'ed sockets with timeouts do not prevent exit. + +const common = require('../common'); +const net = require('net'); + +const server = net.createServer(function(c) { c.write('hello'); c.unref(); }); server.listen(common.PORT); server.unref(); -var timedout = false; var connections = 0; -var sockets = []; -var delays = [8, 5, 3, 6, 2, 4]; +const sockets = []; +const delays = [8, 5, 3, 6, 2, 4]; delays.forEach(function(T) { - var socket = net.createConnection(common.PORT, 'localhost'); - socket.on('connect', function() { + const socket = net.createConnection(common.PORT, 'localhost'); + socket.on('connect', common.mustCall(function() { if (++connections === delays.length) { sockets.forEach(function(s) { - s[0].setTimeout(s[1] * 1000, function() { - timedout = true; - s[0].destroy(); + s.socket.setTimeout(s.timeout, function() { + s.socket.destroy(); + throw new Error('socket timed out unexpectedly'); }); - s[0].unref(); + s.socket.unref(); }); } - }); - - sockets.push([socket, T]); -}); + })); -process.on('exit', function() { - assert.strictEqual(timedout, false, - 'Socket timeout should not hold loop open'); + sockets.push({socket: socket, timeout: T * 1000}); }); From aa9fb03202af513dad7ef5dc901cdaa7d461c9a9 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 1 Apr 2016 23:32:47 -0700 Subject: [PATCH 20/30] doc: use HTTPS for links where possible Provide encrypted links to freenode IRC. PR-URL: https://github.com/nodejs/node/pull/6019 Reviewed-By: James M Snell Reviewed-By: Roman Klauke Reviewed-By: Benjamin Gruenbaum --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5e805ca55d2a95..64264f7c40d983 100644 --- a/README.md +++ b/README.md @@ -114,8 +114,8 @@ Node.js from source. * [CODE_OF_CONDUCT.md](./CODE_OF_CONDUCT.md) * [CONTRIBUTING.md](./CONTRIBUTING.md) * [GOVERNANCE.md](./GOVERNANCE.md) -* IRC (general questions): [#node.js on Freenode.net](http://webchat.freenode.net?channels=node.js&uio=d4) -* IRC (node core development): [#node-dev on Freenode.net](http://webchat.freenode.net?channels=node-dev&uio=d4) +* IRC (general questions): [#node.js on Freenode.net](https://webchat.freenode.net?channels=node.js&uio=d4) +* IRC (node core development): [#node-dev on Freenode.net](https://webchat.freenode.net?channels=node-dev&uio=d4) * [nodejs/node on Gitter](https://gitter.im/nodejs/node) ## Security From 1c4007927dc41dbf8d032700a32b07ee3c2ac83d Mon Sep 17 00:00:00 2001 From: Brian White Date: Sun, 3 Apr 2016 08:37:04 -0400 Subject: [PATCH 21/30] path: fix win32.isAbsolute() inconsistency This commit fixes an inconsistency in absolute path checking compared to the absolute path detection used by the other path.win32 functions. Fixes: https://github.com/nodejs/node/issues/6027 PR-URL: https://github.com/nodejs/node/pull/6028 Reviewed-By: Benjamin Gruenbaum Reviewed-By: James M Snell --- lib/path.js | 60 +++++++------------------------------- test/parallel/test-path.js | 10 +++++++ 2 files changed, 20 insertions(+), 50 deletions(-) diff --git a/lib/path.js b/lib/path.js index 7571918b906fdd..cc1d6e9618d92e 100644 --- a/lib/path.js +++ b/lib/path.js @@ -439,57 +439,17 @@ const win32 = { if (len === 0) return false; var code = path.charCodeAt(0); - if (len > 1) { - if (code === 47/*/*/ || code === 92/*\*/) { - // Possible UNC root - - code = path.charCodeAt(1); - if (code === 47/*/*/ || code === 92/*\*/) { - // Matched double path separator at beginning - var j = 2; - var last = j; - // Match 1 or more non-path separators - for (; j < len; ++j) { - code = path.charCodeAt(j); - if (code === 47/*/*/ || code === 92/*\*/) - break; - } - if (j < len && j !== last) { - // Matched! - last = j; - // Match 1 or more path separators - for (; j < len; ++j) { - code = path.charCodeAt(j); - if (code !== 47/*/*/ && code !== 92/*\*/) - break; - } - if (j < len && j !== last) { - // Matched! - last = j; - // Match 1 or more non-path separators - for (; j < len; ++j) { - code = path.charCodeAt(j); - if (code === 47/*/*/ || code === 92/*\*/) - break; - } - if (j !== last) - return true; - } - } - } - } else if ((code >= 65/*A*/ && code <= 90/*Z*/) || - (code >= 97/*a*/ && code <= 122/*z*/)) { - // Possible device root - - code = path.charCodeAt(1); - if (path.charCodeAt(1) === 58/*:*/ && len > 2) { - code = path.charCodeAt(2); - if (code === 47/*/*/ || code === 92/*\*/) - return true; - } - } - } else if (code === 47/*/*/ || code === 92/*\*/) { + if (code === 47/*/*/ || code === 92/*\*/) { return true; + } else if ((code >= 65/*A*/ && code <= 90/*Z*/) || + (code >= 97/*a*/ && code <= 122/*z*/)) { + // Possible device root + + if (len > 2 && path.charCodeAt(1) === 58/*:*/) { + code = path.charCodeAt(2); + if (code === 47/*/*/ || code === 92/*\*/) + return true; + } } return false; }, diff --git a/test/parallel/test-path.js b/test/parallel/test-path.js index eb49360defd169..f8fb94348d4d75 100644 --- a/test/parallel/test-path.js +++ b/test/parallel/test-path.js @@ -443,8 +443,18 @@ assert.equal(failures.length, 0, failures.join('')); // path.isAbsolute tests +assert.equal(path.win32.isAbsolute('/'), true); +assert.equal(path.win32.isAbsolute('//'), true); +assert.equal(path.win32.isAbsolute('//server'), true); assert.equal(path.win32.isAbsolute('//server/file'), true); assert.equal(path.win32.isAbsolute('\\\\server\\file'), true); +assert.equal(path.win32.isAbsolute('\\\\server'), true); +assert.equal(path.win32.isAbsolute('\\\\'), true); +assert.equal(path.win32.isAbsolute('c'), false); +assert.equal(path.win32.isAbsolute('c:'), false); +assert.equal(path.win32.isAbsolute('c:\\'), true); +assert.equal(path.win32.isAbsolute('c:/'), true); +assert.equal(path.win32.isAbsolute('c://'), true); assert.equal(path.win32.isAbsolute('C:/Users/'), true); assert.equal(path.win32.isAbsolute('C:\\Users\\'), true); assert.equal(path.win32.isAbsolute('C:cwd/another'), false); From 02f2ebd9b49a8017b5e579bd86d6108ba2c6d786 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 2 Apr 2016 23:20:12 -0700 Subject: [PATCH 22/30] test: explicitly set global in test-repl The test intentionally assigns a global. Use `global` namespace to make it clear that it is intentional and not an accidental leak. PR-URL: https://github.com/nodejs/node/pull/6026 Reviewed-By: Ben Noordhuis Reviewed-By: Benjamin Gruenbaum Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-repl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/parallel/test-repl.js b/test/parallel/test-repl.js index 2fa20eb75fd855..02ce8169caf3fe 100644 --- a/test/parallel/test-repl.js +++ b/test/parallel/test-repl.js @@ -24,7 +24,7 @@ var moduleFilename = require('path').join(common.fixturesDir, 'a'); console.error('repl test'); // function for REPL to run -invoke_me = function(arg) { +global.invoke_me = function(arg) { return 'invoked ' + arg; }; From 7db7a820b9b8399fe275bc8d1f3ac6d32f1cd062 Mon Sep 17 00:00:00 2001 From: Santiago Gimeno Date: Fri, 1 Apr 2016 10:22:41 +0200 Subject: [PATCH 23/30] test: make arch available in status files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The value is retrieved from `process.arch` in node itself. PR-URL: https://github.com/nodejs/node/pull/5997 Reviewed-By: João Reis Reviewed-By: James M Snell Reviewed-By: Johan Bergström --- tools/test.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/test.py b/tools/test.py index 9b5dcd735f892b..3cd2778930c8ab 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1523,10 +1523,15 @@ def Main(): if not exists(vm): print "Can't find shell executable: '%s'" % vm continue + archEngineContext = Execute([vm, "-p", "process.arch"], context) + vmArch = archEngineContext.stdout.rstrip() + if archEngineContext.exit_code is not 0 or vmArch == "undefined": + print "Can't determine the arch of: '%s'" % vm + continue env = { 'mode': mode, 'system': utils.GuessOS(), - 'arch': arch, + 'arch': vmArch, } test_list = root.ListTests([], path, context, arch, mode) unclassified_tests += test_list From cc8fcc5a0704bf3fca7dcd5cb81e9775fc0e4a0f Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 1 Apr 2016 22:39:35 -0700 Subject: [PATCH 24/30] test: be explicit about polluting of `global` There was a comment in `test-domain-crypto.js` indicating that the pollution of the `global` object with a `domain` property was intentional. Provide more information in the comment so someone may easily determine why. Use `global.domain` rather than declaring `domain` without the `var` keyword to more clearly signal that the pollution is intentional. PR-URL: https://github.com/nodejs/node/pull/6017 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Colin Ihrig --- test/parallel/test-domain-crypto.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/parallel/test-domain-crypto.js b/test/parallel/test-domain-crypto.js index e76e8d08791c87..4dd979dafeab73 100644 --- a/test/parallel/test-domain-crypto.js +++ b/test/parallel/test-domain-crypto.js @@ -6,8 +6,9 @@ try { return; } -// the missing var keyword is intentional -domain = require('domain'); +// Pollution of global is intentional as part of test. +// See https://github.com/nodejs/node/commit/d1eff9ab +global.domain = require('domain'); // should not throw a 'TypeError: undefined is not a function' exception crypto.randomBytes(8); From 059b607a4fedaf8f15fc70dbb2e093b0e1dd7d96 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Fri, 1 Apr 2016 22:20:55 -0700 Subject: [PATCH 25/30] test: make use of globals explicit Use `global` to be explicit that a global variable is intended. PR-URL: https://github.com/nodejs/node/pull/6014 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- test/parallel/test-vm-static-this.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/test/parallel/test-vm-static-this.js b/test/parallel/test-vm-static-this.js index a5f5ad9415a828..143e4e12216d5e 100644 --- a/test/parallel/test-vm-static-this.js +++ b/test/parallel/test-vm-static-this.js @@ -14,25 +14,25 @@ assert.throws(function() { vm.runInThisContext('throw new Error(\'test\');'); }, /test/); -hello = 5; +global.hello = 5; vm.runInThisContext('hello = 2'); -assert.equal(2, hello); +assert.equal(2, global.hello); console.error('pass values'); -code = 'foo = 1;' + +var code = 'foo = 1;' + 'bar = 2;' + 'if (typeof baz !== \'undefined\') throw new Error(\'test fail\');'; -foo = 2; -obj = { foo: 0, baz: 3 }; +global.foo = 2; +global.obj = { foo: 0, baz: 3 }; /* eslint-disable no-unused-vars */ var baz = vm.runInThisContext(code); /* eslint-enable no-unused-vars */ -assert.equal(0, obj.foo); -assert.equal(2, bar); -assert.equal(1, foo); +assert.equal(0, global.obj.foo); +assert.equal(2, global.bar); +assert.equal(1, global.foo); console.error('call a function'); -f = function() { foo = 100; }; +global.f = function() { global.foo = 100; }; vm.runInThisContext('f()'); -assert.equal(100, foo); +assert.equal(100, global.foo); From 0f5a51ae4b7691d9a21751914c21a83b9115984e Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 26 Mar 2016 03:29:13 +0100 Subject: [PATCH 26/30] assert: Check typed array view type in deepEqual Do not convert typed arrays to `Buffer` for deepEqual since their values may not be accurately represented by 8-bit ints. Instead perform binary comparison of underlying `ArrayBuffer`s, but only when the array types match. Never apply any kind of optimization for floating-point typed arrays since bit pattern equality is not the right kind of check for them. PR-URL: https://github.com/nodejs/node/pull/5910 Reviewed-By: Benjamin Gruenbaum Fixes: https://github.com/nodejs/node/issues/5907 --- lib/assert.js | 17 +++++++++++++---- .../test-assert-typedarray-deepequal.js | 16 ++++++++++++++-- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/lib/assert.js b/lib/assert.js index b33dbfa6cd1d4c..a9bea747f03352 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -29,6 +29,7 @@ const compare = process.binding('buffer').compare; const util = require('util'); const Buffer = require('buffer').Buffer; const pSlice = Array.prototype.slice; +const pToString = (obj) => Object.prototype.toString.call(obj); // 1. The assert module provides functions that throw // AssertionError's when particular conditions are not met. The @@ -170,10 +171,18 @@ function _deepEqual(actual, expected, strict) { (expected === null || typeof expected !== 'object')) { return strict ? actual === expected : actual == expected; - // If both values are instances of typed arrays, wrap them in - // a Buffer each to increase performance - } else if (ArrayBuffer.isView(actual) && ArrayBuffer.isView(expected)) { - return compare(new Buffer(actual), new Buffer(expected)) === 0; + // If both values are instances of typed arrays, wrap their underlying + // ArrayBuffers in a Buffer each 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. + } else if (ArrayBuffer.isView(actual) && ArrayBuffer.isView(expected) && + pToString(actual) === pToString(expected) && + !(actual instanceof Float32Array || + actual instanceof Float64Array)) { + return compare(Buffer(actual.buffer), + Buffer(expected.buffer)) === 0; // 7.5 For all other Object pairs, including Array objects, equivalence is // determined by having the same number of owned properties (as verified diff --git a/test/parallel/test-assert-typedarray-deepequal.js b/test/parallel/test-assert-typedarray-deepequal.js index 68edefdc175317..be4462de5dff77 100644 --- a/test/parallel/test-assert-typedarray-deepequal.js +++ b/test/parallel/test-assert-typedarray-deepequal.js @@ -20,13 +20,25 @@ const equalArrayPairs = [ [new Int16Array(1e5), new Int16Array(1e5)], [new Int32Array(1e5), new Int32Array(1e5)], [new Float32Array(1e5), new Float32Array(1e5)], - [new Float64Array(1e5), new Float64Array(1e5)] + [new Float64Array(1e5), new Float64Array(1e5)], + [new Int16Array(256), new Uint16Array(256)], + [new Int16Array([256]), new Uint16Array([256])], + [new Float32Array([+0.0]), new Float32Array([-0.0])], + [new Float64Array([+0.0]), new Float32Array([-0.0])], + [new Float64Array([+0.0]), new Float64Array([-0.0])] ]; const notEqualArrayPairs = [ [new Uint8Array(2), new Uint8Array(3)], [new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])], - [new Uint8ClampedArray([300, 2, 3]), new Uint8Array([300, 2, 3])] + [new Uint8ClampedArray([300, 2, 3]), new Uint8Array([300, 2, 3])], + [new Uint16Array([2]), new Uint16Array([3])], + [new Uint16Array([0]), new Uint16Array([256])], + [new Int16Array([0]), new Uint16Array([256])], + [new Int16Array([-256]), new Uint16Array([0xff00])], // same bits + [new Int32Array([-256]), new Uint32Array([0xffffff00])], // ditto + [new Float32Array([0.1]), new Float32Array([0.0])], + [new Float64Array([0.1]), new Float64Array([0.0])] ]; equalArrayPairs.forEach((arrayPair) => { From 50a062e69107552e378934cda08edad5e3dd5969 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 30 Mar 2016 12:34:24 -0700 Subject: [PATCH 27/30] tools: remove obsolete lint config file All JS files have been moved out of the `src` directory so the `.eslintrc` file in that directory can also be removed. PR-URL: https://github.com/nodejs/node/pull/5959 Reviewed-By: Jeremiah Senkpiel Reviewed-By: Colin Ihrig Reviewed-By: Roman Klauke --- src/.eslintrc | 4 ---- 1 file changed, 4 deletions(-) delete mode 100644 src/.eslintrc diff --git a/src/.eslintrc b/src/.eslintrc deleted file mode 100644 index c3331b1c652dea..00000000000000 --- a/src/.eslintrc +++ /dev/null @@ -1,4 +0,0 @@ -rules: - # ECMAScript-6 - # http://eslint.org/docs/rules/#ecmascript-6 - prefer-template: 2 From 831777892558de7f6d408d56b48c6a9cd7198bba Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Mon, 29 Feb 2016 12:13:22 +0100 Subject: [PATCH 28/30] meta: add "joining a wg" section to WORKING_GROUPS.md In the WORKING_GROUPS.md documentation, it is described how to start a wg, but not how to join an existing wg. This commit addresses that issue. Fixes: https://github.com/nodejs/node/issues/5448 PR-URL: https://github.com/nodejs/node/pull/5488 Reviewed-By: Rod Vagg Reviewed-By: James M Snell --- WORKING_GROUPS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/WORKING_GROUPS.md b/WORKING_GROUPS.md index 4ae845c3960114..79632c4fd8a4fb 100644 --- a/WORKING_GROUPS.md +++ b/WORKING_GROUPS.md @@ -300,6 +300,11 @@ It's responsibilities are: * Working with the Build Working Group to improve continuous integration. * Improving tooling for testing. +## Joining a WG + +To find out how to join a working group, consult the GOVERNANCE.md in +the working group's repository, or simply open an issue there. + ## Starting a WG A Working Group is established by first defining a charter that can be From 781290b61d7194e142526cc22fb24abeaf82153e Mon Sep 17 00:00:00 2001 From: Robert Jefe Lindstaedt Date: Fri, 19 Feb 2016 21:17:24 +0100 Subject: [PATCH 29/30] doc: refine child_process detach behaviour this adds an example of a long running node process that actually executes node code. Also it mentions the not to harmonic detach behaviours of the different platforms, whereas detaching on unix requires ignoring the child_process' stdio explicitely. PR-URL: https://github.com/nodejs/node/pull/5330 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell --- doc/api/child_process.markdown | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/doc/api/child_process.markdown b/doc/api/child_process.markdown index c4be598ecd9ab2..ae0b8ac9ed0afb 100644 --- a/doc/api/child_process.markdown +++ b/doc/api/child_process.markdown @@ -405,8 +405,27 @@ Doing so will cause the parent's event loop to not include the child in its reference count, allowing the parent to exit independently of the child, unless there is an established IPC channel between the child and parent. -Example of detaching a long-running process and redirecting its output to a -file: +When using the `detached` option to start a long-running process, the process +will not stay running in the background after the parent exits unless it is +provided with a `stdio` configuration that is not connected to the parent. +If the parent's `stdio` is inherited, the child will remain attached to the +controlling terminal. + +Example of a long-running process, by detaching and also ignoring its parent +`stdio` file descriptors, in order to ignore the parent's termination: + +```js +const spawn = require('child_process').spawn; + +const child = spawn(process.argv[0], ['child_program.js'], { + detached: true, + stdio: ['ignore'] +}); + +child.unref(); +``` + +Alternatively one can redirect the child process' output into files: ```js const fs = require('fs'); @@ -422,12 +441,6 @@ const child = spawn('prg', [], { child.unref(); ``` -When using the `detached` option to start a long-running process, the process -will not stay running in the background after the parent exits unless it is -provided with a `stdio` configuration that is not connected to the parent. -If the parent's `stdio` is inherited, the child will remain attached to the -controlling terminal. - #### options.stdio The `options.stdio` option is used to configure the pipes that are established From 5c4a41406b2b7c6aa3c456e6d8fb6533be0a9a3d Mon Sep 17 00:00:00 2001 From: Myles Borins Date: Tue, 5 Apr 2016 11:14:35 -0700 Subject: [PATCH 30/30] 2016-04-05, Version 5.10.1 (Stable) Release Notable changes: http: * Enclose IPv6 Host header in square brackets. This will enable proper seperation of the host adress from any port reference (Mihai Potra) https://github.com/nodejs/node/pull/5314 path: * Make win32.isAbsolute more consistent (Brian White) https://github.com/nodejs/node/pull/6028 PR-URL: https://github.com/nodejs/node/pull/6060 Reviewed-By: Jeremiah Senkpiel --- CHANGELOG.md | 43 +++++++++++++++++++++++++++++++++++++++++++ src/node_version.h | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21345ce5818212..9f4f63ed3f5606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,48 @@ # Node.js ChangeLog +## 2016-04-05, Version 5.10.1 (Stable), @thealphanerd + +### Notable changes + +**http**: + * Enclose IPv6 Host header in square brackets. This will enable proper seperation of the host adress from any port reference (Mihai Potra) [#5314](https://github.com/nodejs/node/pull/5314) + +**path**: + * Make win32.isAbsolute more consistent (Brian White) [#6028](https://github.com/nodejs/node/pull/6028) + +### Commits + +* [[`0f5a51ae4b`](https://github.com/nodejs/node/commit/0f5a51ae4b)] - **assert**: Check typed array view type in deepEqual (Anna Henningsen) [#5910](https://github.com/nodejs/node/pull/5910) +* [[`e966d1f5db`](https://github.com/nodejs/node/commit/e966d1f5db)] - **buffer**: don't set `kNoZeroFill` flag in allocUnsafe (Vladimir Kurchatkin) [#6007](https://github.com/nodejs/node/pull/6007) +* [[`3f75751c2e`](https://github.com/nodejs/node/commit/3f75751c2e)] - **build**: introduce ci targets for lint/benchmark (Johan Bergström) [#5921](https://github.com/nodejs/node/pull/5921) +* [[`781290b61d`](https://github.com/nodejs/node/commit/781290b61d)] - **doc**: refine child_process detach behaviour (Robert Jefe Lindstaedt) [#5330](https://github.com/nodejs/node/pull/5330) +* [[`aa9fb03202`](https://github.com/nodejs/node/commit/aa9fb03202)] - **doc**: use HTTPS for links where possible (Rich Trott) [#6019](https://github.com/nodejs/node/pull/6019) +* [[`dd25984838`](https://github.com/nodejs/node/commit/dd25984838)] - **doc**: note assert.throws() pitfall (Rich Trott) [#6029](https://github.com/nodejs/node/pull/6029) +* [[`f879f5e68a`](https://github.com/nodejs/node/commit/f879f5e68a)] - **doc**: document unspecified behavior for buf.write* methods (James M Snell) [#5925](https://github.com/nodejs/node/pull/5925) +* [[`f12c3861e0`](https://github.com/nodejs/node/commit/f12c3861e0)] - **doc**: clarify stdout/stderr arguments to callback (James M Snell) [#6015](https://github.com/nodejs/node/pull/6015) +* [[`ce173716be`](https://github.com/nodejs/node/commit/ce173716be)] - **doc**: add 'Command Line Options' to 'View on single page' (firedfox) [#6011](https://github.com/nodejs/node/pull/6011) +* [[`7337ef6422`](https://github.com/nodejs/node/commit/7337ef6422)] - **doc**: minor argument formatting in stream.markdown (James M Snell) [#6016](https://github.com/nodejs/node/pull/6016) +* [[`0ae5d027c6`](https://github.com/nodejs/node/commit/0ae5d027c6)] - **doc**: clarify that __dirname is module local (James M Snell) [#6018](https://github.com/nodejs/node/pull/6018) +* [[`8bec8aa41f`](https://github.com/nodejs/node/commit/8bec8aa41f)] - **doc**: consolidate timers docs in timers.markdown (Bryan English) [#5837](https://github.com/nodejs/node/pull/5837) +* [[`0a13099c42`](https://github.com/nodejs/node/commit/0a13099c42)] - **etw**: add event messages (João Reis) [#5936](https://github.com/nodejs/node/pull/5936) +* [[`c6ac6f2ea1`](https://github.com/nodejs/node/commit/c6ac6f2ea1)] - **http**: Corrects IPv6 address in Host header (Mihai Potra) [#5314](https://github.com/nodejs/node/pull/5314) +* [[`8317778925`](https://github.com/nodejs/node/commit/8317778925)] - **meta**: add "joining a wg" section to WORKING_GROUPS.md (Matteo Collina) [#5488](https://github.com/nodejs/node/pull/5488) +* [[`f3f19ee5e2`](https://github.com/nodejs/node/commit/f3f19ee5e2)] - **net**: refactor self=this to arrow functions (Benjamin Gruenbaum) [#5857](https://github.com/nodejs/node/pull/5857) +* [[`1c4007927d`](https://github.com/nodejs/node/commit/1c4007927d)] - **path**: fix win32.isAbsolute() inconsistency (Brian White) [#6028](https://github.com/nodejs/node/pull/6028) +* [[`059b607a4f`](https://github.com/nodejs/node/commit/059b607a4f)] - **test**: make use of globals explicit (Rich Trott) [#6014](https://github.com/nodejs/node/pull/6014) +* [[`cc8fcc5a07`](https://github.com/nodejs/node/commit/cc8fcc5a07)] - **test**: be explicit about polluting of `global` (Rich Trott) [#6017](https://github.com/nodejs/node/pull/6017) +* [[`7db7a820b9`](https://github.com/nodejs/node/commit/7db7a820b9)] - **test**: make arch available in status files (Santiago Gimeno) [#5997](https://github.com/nodejs/node/pull/5997) +* [[`02f2ebd9b4`](https://github.com/nodejs/node/commit/02f2ebd9b4)] - **test**: explicitly set global in test-repl (Rich Trott) [#6026](https://github.com/nodejs/node/pull/6026) +* [[`2ab1237137`](https://github.com/nodejs/node/commit/2ab1237137)] - **test**: fix flaky test-net-socket-timeout-unref (Rich Trott) [#6003](https://github.com/nodejs/node/pull/6003) +* [[`0127c2bd39`](https://github.com/nodejs/node/commit/0127c2bd39)] - **test**: fix test-dns.js flakiness (Rich Trott) [#5996](https://github.com/nodejs/node/pull/5996) +* [[`6052ced37f`](https://github.com/nodejs/node/commit/6052ced37f)] - **test**: fix error message checks in test-module-loading (James M Snell) [#5986](https://github.com/nodejs/node/pull/5986) +* [[`a40b0cb673`](https://github.com/nodejs/node/commit/a40b0cb673)] - **test**: refactor http-end-throw-socket-handling (Santiago Gimeno) [#5676](https://github.com/nodejs/node/pull/5676) +* [[`96bb315262`](https://github.com/nodejs/node/commit/96bb315262)] - **test**: ensure _handle property existence (Rich Trott) [#5916](https://github.com/nodejs/node/pull/5916) +* [[`4f1fa2adeb`](https://github.com/nodejs/node/commit/4f1fa2adeb)] - **test**: fix offending max-len linter error (Sakthipriyan Vairamani) [#5980](https://github.com/nodejs/node/pull/5980) +* [[`f14d71ccea`](https://github.com/nodejs/node/commit/f14d71ccea)] - **test**: stdin is not always a net.Socket (Jeremiah Senkpiel) [#5935](https://github.com/nodejs/node/pull/5935) +* [[`50a062e691`](https://github.com/nodejs/node/commit/50a062e691)] - **tools**: remove obsolete lint config file (Rich Trott) [#5959](https://github.com/nodejs/node/pull/5959) +* [[`7491fdcfe9`](https://github.com/nodejs/node/commit/7491fdcfe9)] - **tools**: remove disabling of already-disabled rule (Rich Trott) [#6013](https://github.com/nodejs/node/pull/6013) + ## 2016-03-31, Version 5.10.0 (Stable), @evanlucas ### Notable changes diff --git a/src/node_version.h b/src/node_version.h index 071ad69d614716..69389caa2c03d2 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -5,7 +5,7 @@ #define NODE_MINOR_VERSION 10 #define NODE_PATCH_VERSION 1 -#define NODE_VERSION_IS_RELEASE 0 +#define NODE_VERSION_IS_RELEASE 1 #ifndef NODE_STRINGIFY #define NODE_STRINGIFY(n) NODE_STRINGIFY_HELPER(n)