Skip to content
This repository was archived by the owner on Oct 15, 2020. It is now read-only.

Commit 967a8d2

Browse files
committedJan 20, 2018
meta: merge node/master into node-chakracore/master
Merge 4117e22 as of 2017-12-29 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: Taylor Woll <[email protected]>
2 parents 159dcd5 + 4117e22 commit 967a8d2

13 files changed

+108
-54
lines changed
 

‎doc/api/http.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ added: v0.9.12
911911
The number of milliseconds of inactivity before a socket is presumed
912912
to have timed out.
913913

914-
A value of 0 will disable the timeout behavior on incoming connections.
914+
A value of `0` will disable the timeout behavior on incoming connections.
915915

916916
*Note*: The socket timeout logic is set up on connection, so changing this
917917
value only affects new connections to the server, not any existing connections.
@@ -929,7 +929,9 @@ will be destroyed. If the server receives new data before the keep-alive
929929
timeout has fired, it will reset the regular inactivity timeout, i.e.,
930930
[`server.timeout`][].
931931

932-
A value of 0 will disable the keep-alive timeout behavior on incoming connections.
932+
A value of `0` will disable the keep-alive timeout behavior on incoming connections.
933+
A value of `0` makes the http server behave similarly to Node.js versions prior to 8.0.0,
934+
which did not have a keep-alive timeout.
933935

934936
*Note*: The socket timeout logic is set up on connection, so changing this
935937
value only affects new connections to the server, not any existing connections.

‎lib/assert.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,15 @@ assert.ifError = function ifError(err) { if (err) throw err; };
320320

321321
// Expose a strict only variant of assert
322322
function strict(value, message) {
323-
if (!value) innerFail(value, true, message, '==', strict);
323+
if (!value) {
324+
innerFail({
325+
actual: value,
326+
expected: true,
327+
message,
328+
operator: '==',
329+
stackStartFn: strict
330+
});
331+
}
324332
}
325333
assert.strict = Object.assign(strict, assert, {
326334
equal: assert.strictEqual,

‎lib/internal/http.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
'use strict';
22

3-
const timers = require('timers');
3+
const { setUnrefTimeout } = require('internal/timers');
44

55
var dateCache;
66
function utcDate() {
77
if (!dateCache) {
88
const d = new Date();
99
dateCache = d.toUTCString();
10-
timers.enroll(utcDate, 1000 - d.getMilliseconds());
11-
timers._unrefActive(utcDate);
10+
11+
setUnrefTimeout(resetCache, 1000 - d.getMilliseconds());
1212
}
1313
return dateCache;
1414
}
15-
utcDate._onTimeout = function() {
15+
16+
function resetCache() {
1617
dateCache = undefined;
17-
};
18+
}
1819

1920
function ondrain() {
2021
if (this._httpMessage) this._httpMessage.emit('drain');

‎lib/util.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -1056,9 +1056,12 @@ function error(...args) {
10561056
}
10571057

10581058
function _errnoException(err, syscall, original) {
1059-
if (typeof err !== 'number' || err >= 0 || !Number.isSafeInteger(err)) {
1060-
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'err',
1061-
'negative number');
1059+
if (typeof err !== 'number') {
1060+
throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'err', 'number', err);
1061+
}
1062+
if (err >= 0 || !Number.isSafeInteger(err)) {
1063+
throw new errors.RangeError('ERR_OUT_OF_RANGE', 'err',
1064+
'a negative integer', err);
10621065
}
10631066
const name = errname(err);
10641067
var message = `${syscall} ${name}`;
@@ -1093,10 +1096,6 @@ function _exceptionWithHostPort(err,
10931096
return ex;
10941097
}
10951098

1096-
// process.versions needs a custom function as some values are lazy-evaluated.
1097-
process.versions[inspect.custom] =
1098-
() => exports.format(JSON.parse(JSON.stringify(process.versions)));
1099-
11001099
function callbackifyOnRejected(reason, cb) {
11011100
// `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
11021101
// Because `null` is a special error value in callbacks which means "no error

‎test/parallel/test-accessor-properties.js

+25-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
require('../common');
3+
const common = require('../common');
44

55
// This tests that the accessor properties do not raise assertions
66
// when called with incompatible receivers.
@@ -12,9 +12,6 @@ const assert = require('assert');
1212
const TTY = process.binding('tty_wrap').TTY;
1313
const UDP = process.binding('udp_wrap').UDP;
1414

15-
// There are accessor properties in crypto too
16-
const crypto = process.binding('crypto');
17-
1815
{
1916
// Should throw instead of raise assertions
2017
assert.throws(() => {
@@ -33,15 +30,6 @@ const crypto = process.binding('crypto');
3330
UDP.prototype.fd;
3431
}, TypeError);
3532

36-
assert.throws(() => {
37-
crypto.SecureContext.prototype._external;
38-
}, TypeError);
39-
40-
assert.throws(() => {
41-
crypto.Connection.prototype._external;
42-
}, TypeError);
43-
44-
4533
// Should not throw for Object.getOwnPropertyDescriptor
4634
assert.strictEqual(
4735
typeof Object.getOwnPropertyDescriptor(TTY.prototype, 'bytesRead'),
@@ -63,15 +51,28 @@ const crypto = process.binding('crypto');
6351
'object'
6452
);
6553

66-
assert.strictEqual(
67-
typeof Object.getOwnPropertyDescriptor(
68-
crypto.SecureContext.prototype, '_external'),
69-
'object'
70-
);
71-
72-
assert.strictEqual(
73-
typeof Object.getOwnPropertyDescriptor(
74-
crypto.Connection.prototype, '_external'),
75-
'object'
76-
);
54+
if (common.hasCrypto) { // eslint-disable-line crypto-check
55+
// There are accessor properties in crypto too
56+
const crypto = process.binding('crypto');
57+
58+
assert.throws(() => {
59+
crypto.SecureContext.prototype._external;
60+
}, TypeError);
61+
62+
assert.throws(() => {
63+
crypto.Connection.prototype._external;
64+
}, TypeError);
65+
66+
assert.strictEqual(
67+
typeof Object.getOwnPropertyDescriptor(
68+
crypto.SecureContext.prototype, '_external'),
69+
'object'
70+
);
71+
72+
assert.strictEqual(
73+
typeof Object.getOwnPropertyDescriptor(
74+
crypto.Connection.prototype, '_external'),
75+
'object'
76+
);
77+
}
7778
}

‎test/parallel/test-assert.js

+8
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,14 @@ common.expectsError(
753753
assert.equal(Object.keys(assert).length, Object.keys(a).length);
754754
/* eslint-enable no-restricted-properties */
755755
assert(7);
756+
common.expectsError(
757+
() => assert(),
758+
{
759+
code: 'ERR_ASSERTION',
760+
type: assert.AssertionError,
761+
message: 'undefined == true'
762+
}
763+
);
756764
}
757765

758766
common.expectsError(

‎test/parallel/test-child-process-fork-net2.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ if (process.argv[2] === 'child') {
3333
process.on('message', function(m, socket) {
3434
if (!socket) return;
3535

36-
console.error('[%d] got socket', id, m);
36+
console.error(`[${id}] got socket ${m}`);
3737

3838
// will call .end('end') or .write('write');
3939
socket[m](m);
4040

4141
socket.resume();
4242

4343
socket.on('data', function() {
44-
console.error('[%d] socket.data', id, m);
44+
console.error(`[${id}] socket.data ${m}`);
4545
});
4646

4747
socket.on('end', function() {
48-
console.error('[%d] socket.end', id, m);
48+
console.error(`[${id}] socket.end ${m}`);
4949
});
5050

5151
// store the unfinished socket
@@ -54,27 +54,27 @@ if (process.argv[2] === 'child') {
5454
}
5555

5656
socket.on('close', function(had_error) {
57-
console.error('[%d] socket.close', id, had_error, m);
57+
console.error(`[${id}] socket.close ${had_error} ${m}`);
5858
});
5959

6060
socket.on('finish', function() {
61-
console.error('[%d] socket finished', id, m);
61+
console.error(`[${id}] socket finished ${m}`);
6262
});
6363
});
6464

6565
process.on('message', function(m) {
6666
if (m !== 'close') return;
67-
console.error('[%d] got close message', id);
67+
console.error(`[${id}] got close message`);
6868
needEnd.forEach(function(endMe, i) {
69-
console.error('[%d] ending %d/%d', id, i, needEnd.length);
69+
console.error(`[${id}] ending ${i}/${needEnd.length}`);
7070
endMe.end('end');
7171
});
7272
});
7373

7474
process.on('disconnect', function() {
75-
console.error('[%d] process disconnect, ending', id);
75+
console.error(`[${id}] process disconnect, ending`);
7676
needEnd.forEach(function(endMe, i) {
77-
console.error('[%d] ending %d/%d', id, i, needEnd.length);
77+
console.error(`[${id}] ending ${i}/${needEnd.length}`);
7878
endMe.end('end');
7979
});
8080
});
@@ -107,7 +107,7 @@ if (process.argv[2] === 'child') {
107107
connected += 1;
108108

109109
socket.once('close', function() {
110-
console.log('[m] socket closed, total %d', ++closed);
110+
console.log(`[m] socket closed, total ${++closed}`);
111111
});
112112

113113
if (connected === count) {

‎test/parallel/test-http2-util-headers-list.js

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
// to pass to the internal binding layer.
66

77
const common = require('../common');
8+
if (!common.hasCrypto)
9+
common.skip('missing crypto');
810
const assert = require('assert');
911
const { mapToHeaders } = require('internal/http2/util');
1012

‎test/parallel/test-http2-util-update-options-buffer.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
// Flags: --expose-internals
22
'use strict';
33

4-
require('../common');
4+
const common = require('../common');
5+
if (!common.hasCrypto)
6+
common.skip('missing crypto');
57

68
// Test coverage for the updateOptionsBuffer method used internally
79
// by the http2 implementation.

‎test/parallel/test-repl-tab-complete.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ editor.completer('var log = console.l', common.mustCall((error, data) => {
544544

545545
['Let', 'Const', 'Klass'].forEach((type) => {
546546
const query = `lexical${type[0]}`;
547-
const expected = hasInspector ? [[`lexical${type}`], query] : [];
547+
const expected = hasInspector ? [[`lexical${type}`], query] :
548+
[[], `lexical${type[0]}`];
548549
testRepl.complete(query, common.mustCall((error, data) => {
549550
assert.deepStrictEqual(data, expected);
550551
}));

‎test/parallel/test-uv-errno.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,25 @@ keys.forEach((key) => {
2020
});
2121
});
2222

23-
[0, 1, 'test', {}, [], Infinity, -Infinity, NaN].forEach((key) => {
23+
['test', {}, []].forEach((key) => {
2424
common.expectsError(
2525
() => util._errnoException(key),
2626
{
2727
code: 'ERR_INVALID_ARG_TYPE',
2828
type: TypeError,
29-
message: 'The "err" argument must be of type negative number'
29+
message: 'The "err" argument must be of type number. ' +
30+
`Received type ${typeof key}`
31+
});
32+
});
33+
34+
[0, 1, Infinity, -Infinity, NaN].forEach((key) => {
35+
common.expectsError(
36+
() => util._errnoException(key),
37+
{
38+
code: 'ERR_OUT_OF_RANGE',
39+
type: RangeError,
40+
message: 'The value of "err" is out of range. ' +
41+
'It must be a negative integer. ' +
42+
`Received ${key}`
3043
});
3144
});

‎tools/eslint-rules/crypto-check.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@ const utils = require('./rules-utils.js');
1616
const msg = 'Please add a hasCrypto check to allow this test to be skipped ' +
1717
'when Node is built "--without-ssl".';
1818

19+
const cryptoModules = ['crypto', 'http2'];
20+
const requireModules = cryptoModules.concat(['tls', 'https']);
21+
const bindingModules = cryptoModules.concat(['tls_wrap']);
22+
1923
module.exports = function(context) {
2024
const missingCheckNodes = [];
2125
const requireNodes = [];
2226
var hasSkipCall = false;
2327

2428
function testCryptoUsage(node) {
25-
if (utils.isRequired(node, ['crypto', 'tls', 'https', 'http2'])) {
29+
if (utils.isRequired(node, requireModules) ||
30+
utils.isBinding(node, bindingModules)) {
2631
requireNodes.push(node);
2732
}
2833
}

‎tools/eslint-rules/rules-utils.js

+12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ module.exports.isRequired = function(node, modules) {
1212
modules.includes(node.arguments[0].value);
1313
};
1414

15+
/**
16+
* Returns true if any of the passed in modules are used in
17+
* binding calls.
18+
*/
19+
module.exports.isBinding = function(node, modules) {
20+
if (node.callee.object) {
21+
return node.callee.object.name === 'process' &&
22+
node.callee.property.name === 'binding' &&
23+
modules.includes(node.arguments[0].value);
24+
}
25+
};
26+
1527
/**
1628
* Returns true is the node accesses any property in the properties
1729
* array on the 'common' object.

0 commit comments

Comments
 (0)
This repository has been archived.