0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
Commit Graph

15861 Commits

Author SHA1 Message Date
Nate
5f55faa1a0 test: add regex to text-crypto-random
PR-URL: https://github.com/nodejs/node/pull/10020
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
2016-12-27 21:56:44 -08:00
Matt Crummey
109bfd21d8 doc: improve rinfo object documentation
Provide details for fields of rinfo object of UDP message event.

PR-URL: https://github.com/nodejs/node/pull/10050
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-27 21:31:01 -08:00
Sarah Meyer
a9b59ff8fb test: add test for SIGWINCH handling by stdio.js
PR-URL: https://github.com/nodejs/node/pull/10063
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-27 21:21:35 -08:00
Adrian Estrada
b85f9fec2f test: refactor the code in test-fs-chmod
* use const and let instead of var
* use common.mustCall to control functions executions
* use assert.strictEqual instead of assert.equal
* use assert.ifError to handle errors
* use arrow functions
* remove unnecessary variables

PR-URL: https://github.com/nodejs/node/pull/10440
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-12-27 18:18:41 -08:00
Brian White
13a4887ee9 buffer: improve allocation performance
assertSize() is adjusted to be inlineable according to V8's default
function size limits when determining inlineability. This results in
up to 11% performance gains when allocating any kind of Buffer.

Avoid avoids use of in, resulting in ~50% improvement when creating
a Buffer from an array-like object.

PR-URL: https://github.com/nodejs/node/pull/10443
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2016-12-27 14:57:06 -08:00
Christopher J. Brody
595b22affa url: mark ignored return value in node::url::Parse(...)
This is to resolve an unused result warning in node_url.cc.
Resolve macro redefinition warning on Windows

PR-URL: https://github.com/nodejs/node/pull/10141
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2016-12-27 14:44:32 -08:00
Christopher J. Brody
099762de61 dtrace: resolve conversion warnings from SLURP_INT
Resolve build warnings on Windows with the following pattern:
warning C4244: '=': conversion from 'int64_t' to 'int32_t',
possible loss of data

PR-URL: https://github.com/nodejs/node/pull/10143
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-27 14:37:13 -08:00
Paul Graham
ecd11b6e26 test: swap var for let/const throughout
Swap var for let/const throughout the common.js module.
Change a snake case variable to camel case starting on line 168.

PR-URL: https://github.com/nodejs/node/pull/10177
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-27 14:25:03 -08:00
jBarz
1c3c75dac2 os: fix os.release() for aix and add test
PR-URL: https://github.com/nodejs/node/pull/10245
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-27 14:01:49 -08:00
Sam Roberts
97ab4b2998 doc: add tls.DEFAULT_ECDH_CURVE
A user can change the default curve for ECDH key agreement by
using tls.DEFAULT_ECDH_CURVE.

PR-URL: https://github.com/nodejs/node/pull/10264
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Shigeki Ohtsu <ohtsu@iij.ad.jp>
2016-12-27 13:56:51 -08:00
Jesús Leganés-Combarro 'piranna
8e60e0f833 build: add (not) cross-compiled configure flags
Adds --cross-compiling and --no-cross-compiling flags

Fixes: https://github.com/nodejs/node/issues/10271
PR-URL: https://github.com/nodejs/node/pull/10287
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-12-27 13:47:30 -08:00
Fumiya KARASAWA
37d6052867 doc: fixup errors in stream.md
When decodeStrings is false and given data is string, _write() function
receives the string data not `Buffer`.

PR-URL: https://github.com/nodejs/node/pull/10411
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-27 13:42:41 -08:00
Sam Roberts
1257546a41 src: describe what NODE_MODULE_VERSION is for
Current comment described what to do with it when the ABI changes, but
implied that Node.js would load modules with newer ABI numbers, which it
will not.

PR-URL: https://github.com/nodejs/node/pull/10414
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
2016-12-27 13:38:43 -08:00
Rich Trott
0dc09eb746 doc: use "Node.js" in V8 guide
PR-URL: https://github.com/nodejs/node/pull/10438
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-27 13:30:18 -08:00
Vse Mozhet Byt
3e4dc60fae doc: more efficient example in the console.md
Object.setPrototypeOf() -> Object.create()

PR-URL: https://github.com/nodejs/node/pull/10451
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-27 13:16:13 -08:00
Vse Mozhet Byt
2b4dfeba1d doc: var -> const / let in the console.md
PR-URL: https://github.com/nodejs/node/pull/10451
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-27 13:16:05 -08:00
Adrian Estrada
fc103bbdc8 test: improve the code in test-pipe.js
* use const and let instead of var
* use common.mustCall to control functions executions
* use assert.strictEqual instead of assert.equal
* use assert.ifError to handle errors
* use arrow functions
* remove console.log and process.stdout.write

PR-URL: https://github.com/nodejs/node/pull/10452
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2016-12-27 13:27:17 -05:00
Eugene Ostroukhov
3e76364be3 inspector: remove unused uv_async_t
PR-URL: https://github.com/nodejs/node/pull/10392
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-27 10:08:01 -08:00
Adrian Estrada
499efbd085 test: improve code in test-fs-readfile-error
* use const instead of var
* use common.mustCall to control the functions execution automatically
* use assert.strictEqual instead of assert.equal
* use assert.notStrictEqual instead of assert.notEqual
* use arrow functions

PR-URL: https://github.com/nodejs/node/pull/10367
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-26 12:45:51 +01:00
Adrian Estrada
89c8f58921 test: improve code in test-vm-preserves-property
* use const instead of var
* use assert.strictEqual instead assert.equal

PR-URL https://github.com/nodejs/node/pull/10428
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2016-12-26 12:41:12 +01:00
Adrian Estrada
7c0d5d5fd9 test: improve code in test-vm-symbols
* use const instead of var
* use assert.strictEqual instead of assert.equal

PR-URL: https://github.com/nodejs/node/pull/10429
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2016-12-26 12:33:08 +01:00
Anna Henningsen
f2ef850f11
fs: support Uint8Array input to methods
Allow `fs.read`, `fs.write` and `fs.writeFile` to take
`Uint8Array` arguments.

PR-URL: https://github.com/nodejs/node/pull/10382
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
2016-12-26 10:08:42 +01:00
Sakthipriyan Vairamani (thefourtheye)
3ef4ec0e93
test: fix and improve debugger-client test
This test expects the string 'Debugger listening on port' on stderr and
since the message has been changed to 'Debugger listening on host:port'
this was failing always.

Apart from that, this test expects the main script's name to be
`src/node.js`, but that has been renamed to `lib/internal/node.js` and
then to `lib/internal/bootstrap_node.js`. So, the script name has been
updated.

Apart from that, using `const` instead of `var` wherever possible.

Refer: https://github.com/nodejs/node/issues/10361

PR-URL: https://github.com/nodejs/node/pull/10371

Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-26 12:47:11 +05:30
Vse Mozhet Byt
f5011786ba
doc: add the valid link for curl(1) in repl.md
The current autoinserted link leads to 404 page.

PR-URL: https://github.com/nodejs/node/pull/10244
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-25 19:50:35 +01:00
Vse Mozhet Byt
5f8aa1fcb1
doc: replace anonymous functions in repl.md
Replaced with an object shorthand and an arrow function.

PR-URL: https://github.com/nodejs/node/pull/10244
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-25 19:50:32 +01:00
Vse Mozhet Byt
224cbf8bd8
doc: fix a function name in repl.md
`eval` => `myEval` to not shadow the global `eval`

PR-URL: https://github.com/nodejs/node/pull/10244
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-25 19:50:29 +01:00
Vse Mozhet Byt
4936c41194
doc: fix an output example in repl.md
Make `_` reassignment example match more with the current output.
Extend the example for more clarity.

PR-URL: https://github.com/nodejs/node/pull/10244
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-25 19:50:25 +01:00
Vse Mozhet Byt
cb507af454
doc: white space unification in repl.md
Add an infix space in an argument list.
Change `>` into `> ` in code bits and output examples.
Explicitly clarify that default REPL prompt contains a trailing space.

PR-URL: https://github.com/nodejs/node/pull/10244
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-25 19:50:22 +01:00
Vse Mozhet Byt
c919dd7788
doc: var => let / const in repl.md
PR-URL: https://github.com/nodejs/node/pull/10244
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-25 19:49:05 +01:00
cjihrig
45c9ca7fd4 src: remove redundant spawn/spawnSync type checks
This commit removes C++ checks from spawn() and spawnSync()
that are duplicates of the JavaScript type checking.

Fixes: https://github.com/nodejs/node/issues/8096
Fixes: https://github.com/nodejs/node/issues/8539
Refs: https://github.com/nodejs/node/issues/9722
PR-URL: https://github.com/nodejs/node/pull/8312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-12-25 12:48:55 -05:00
cjihrig
fc7b0dda85 child_process: improve input validation
This commit applies stricter input validation in
normalizeSpawnArguments(), which is run by all of the
child_process methods. Additional checks are added for spawnSync()
specific inputs.

Fixes: https://github.com/nodejs/node/issues/8096
Fixes: https://github.com/nodejs/node/issues/8539
Refs: https://github.com/nodejs/node/issues/9722
PR-URL: https://github.com/nodejs/node/pull/8312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-12-25 12:48:46 -05:00
cjihrig
b374ee8c3d src: add handle check to spawn_sync
This commit verifies that the child process handle is of the
correct type before trying to close it in
CloseHandlesAndDeleteLoop(). This catches the case where input
validation failed, and the child process was never actually
spawned.

Fixes: https://github.com/nodejs/node/issues/8096
Fixes: https://github.com/nodejs/node/issues/8539
Refs: https://github.com/nodejs/node/issues/9722
PR-URL: https://github.com/nodejs/node/pull/8312
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-12-25 12:46:27 -05:00
Junshu Okamoto
c65d55f087 url: do not truncate long hostnames
Currently, around line 417 lib/url.js is truncating hostname and put the
rest of hostname to the path if hostname length after `.`  is equal or
more than 63. This behavior is different from browser behavior. I
changed the code so that it doesn’t truncate.

I also added the test example which has more than 63 length in after
`.` in hostname in test url.

PR-URL: https://github.com/nodejs/node/pull/9292
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2016-12-24 21:06:23 -08:00
sarahmeyer
c732bd1d93 doc: update CONTRIBUTING.MD with link to V8 guide
Currently, two of the guides in the `/doc/guides` directory are actually
guides for working on the Nodei.js project. Of those, one is linked from
this page. This change adds a note to point people to the other.

PR-URL: https://github.com/nodejs/node/pull/10070
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
2016-12-24 15:47:38 -08:00
larissayvette
66c0767be4 test: basic functionality of readUIntLE()
PR-URL: https://github.com/nodejs/node/pull/10359
Reviewed-By: Julian Duque <julianduquej@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-12-24 15:44:40 -08:00
Joyee Cheung
904b66d870 test: increase coverage of Buffer.transcode
Adds test for transcoding an empty buffer.

PR-URL: https://github.com/nodejs/node/pull/10437
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-24 13:20:39 -08:00
Kailean Courtney
e81e031af7 test: clean up repl-reset-event file
* Change vars to let/const
* Add mustCall
* equal -> strictEqual
* remove timeout

PR-URL: https://github.com/nodejs/node/pull/9931
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-12-24 13:14:03 -08:00
malen
ff88a5a25b test: refactor test-child-process-ipc
Change var to const or let.
Change assert.equal() to assert.strictEqual().

PR-URL: https://github.com/nodejs/node/pull/9990
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
2016-12-24 06:28:50 -08:00
Jeremy Yallop
5dc44874c3 fs: cache non-symlinks in realpathSync.
Extend `fs.realpathSync` to cache the results for paths that are not
symlinks in addition to caching symlink mappings.

PR-URL: https://github.com/nodejs/node/pull/10253
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-23 23:40:45 -08:00
Brian White
17eb8fce05 benchmark: use commas in non-csv rate output
PR-URL: https://github.com/nodejs/node/pull/10360
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-23 23:22:59 -08:00
Sakthipriyan Vairamani (thefourtheye)
c74d9d672e test: fix and improve debug-break-on-uncaught
This test runs based on a expectation that the stderr will get the
string 'Debugger listening on port'. But the actual message printed
to stderr has changed to 'Debugger listening on host:port'. So the
the actuals tests did not even start and eventually timeout.

Apart from that, changed `var`s to `let`s or `const`s.

Refs: https://github.com/nodejs/node/issues/10361
PR-URL: https://github.com/nodejs/node/pull/10370
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com
2016-12-23 23:10:59 -08:00
René Schünemann
c7ff96b0f7 async_wrap: close the destroy_ids_idle_handle_
The destroy_ids_idle_handle_ needs to be closed on
environment destruction. Not closing the handle leaves
a dangling pointer in the used uv loop. This leads to
undefined behavior when the uv loop is used after the
environment has been destroyed.

PR-URL: https://github.com/nodejs/node/pull/10385
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-23 23:00:17 -08:00
Christy Leung
c00f647963 test: refactor test-internal-modules
* var -> const
* add RegExp to assert.throws() to check error message

PR-URL: https://github.com/nodejs/node/pull/10016
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-23 22:48:48 -08:00
Ken Russo
1fddf5b6d6 test: add second argument to assert.throws()
The assert.throws() calls in test-event-emitter-max-listeners.js
should include a constructor or RegExp as a second argument.

PR-URL: https://github.com/nodejs/node/pull/9987
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-23 22:41:35 -08:00
Josh Mays
00da58db7e test: refactor test-pipe-file-to-http
Changing var defs to const/let, changing assert.equal to
assert.strictEqual. Wrapping functions called once with
common.mustCall

PR-URL: https://github.com/nodejs/node/pull/10054
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-12-23 22:08:50 -08:00
Brian Chirgwin
6281a1c3e3 test: refactor test-tls-interleave
var -> let / const
added common.mustCall() to callback
assert.equal() -> assert.strictEqual()

PR-URL: https://github.com/nodejs/node/pull/10017
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-12-23 22:00:48 -08:00
Harish Tejwani
0ff69b46da test: refactor test-tls-client-getephemeralkeyinfo
change var to const and add mustCall

PR-URL: https://github.com/nodejs/node/pull/9954
Reviewed-By: Prince John Wesley <princejohnwesley@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-12-23 21:50:00 -08:00
Amar Zavery
7e7062cdca test: refactor test-cluster-send-handle-twice.js
- `var` --> `const` as applicable
- `assert.equal`  --> `assert.strictEqual`
- `assert(false, ..)` --> `common.fail()`
- `common.mustCall` for functions that need to be called exactly once
- modified an `assert(!signal, 'Worker exited by a signal');` call to
  `assert.strictEqual(signal, null);` call as that made more sense

PR-URL: https://github.com/nodejs/node/pull/10049
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2016-12-23 21:36:47 -08:00
Kevin Cox
b00f8ad13a test: update test-tls-check-server-identity.js
Changed var to const, assert.equal to assert.strictEqual, and
used a template string for error output.

PR-URL: https://github.com/nodejs/node/pull/9986
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-23 20:54:32 -08:00
Rich Trott
3f52ce35bc test: fix flaky test-https-timeout
Remove `setTimeout()` in test and instead rely on `common.mustCall()` on
a `timeout` event handler.

The test was flaky on CI. The flakiness was replicable by running the
test under load. This version, in contrast, is robust under load.

Took the opportunity to do some `var` -> `const` while refactoring.

PR-URL: https://github.com/nodejs/node/pull/10404
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-23 20:43:22 -08:00