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

Commit 65cc69d

Browse files
committed
Merge nodejs/master
Merge 99c478e as of 2017-08-26. This is an automatically created merge. For any problems please contact @kunalspathak.
2 parents 094ccb1 + 99c478e commit 65cc69d

20 files changed

+462
-105
lines changed

benchmark/dns/lookup.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ const lookup = require('dns').lookup;
55

66
const bench = common.createBenchmark(main, {
77
name: ['', '127.0.0.1', '::1'],
8-
all: [true, false],
8+
all: ['true', 'false'],
99
n: [5e6]
1010
});
1111

1212
function main(conf) {
1313
const name = conf.name;
1414
const n = +conf.n;
15-
const all = !!conf.all;
15+
const all = conf.all === 'true' ? true : false;
1616
var i = 0;
1717

1818
if (all) {
1919
const opts = { all: true };
2020
bench.start();
21-
(function cb(err, results) {
21+
(function cb() {
2222
if (i++ === n) {
2323
bench.end(n);
2424
return;
@@ -27,7 +27,7 @@ function main(conf) {
2727
})();
2828
} else {
2929
bench.start();
30-
(function cb(err, result) {
30+
(function cb() {
3131
if (i++ === n) {
3232
bench.end(n);
3333
return;

deps/chakrashim/include/v8-version.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
// Copyright 2015 the V8 project authors. All rights reserved.
2-
// Use of this source code is governed by a BSD-style license that can be
3-
// found in the LICENSE file.
4-
5-
#ifndef V8_INCLUDE_VERSION_H_ // V8_VERSION_H_ conflicts with src/version.h
6-
#define V8_INCLUDE_VERSION_H_
7-
8-
// These macros define the version number for the current version.
9-
// NOTE these macros are used by some of the tool scripts and the build
10-
// system so their names cannot be changed without changing the scripts.
11-
#define V8_MAJOR_VERSION 6
12-
#define V8_MINOR_VERSION 0
13-
#define V8_BUILD_NUMBER 287
14-
#define V8_PATCH_LEVEL 53
15-
16-
// Use 1 for candidates and 0 otherwise.
17-
// (Boolean macro values are not supported by all preprocessors.)
18-
#define V8_IS_CANDIDATE_VERSION 0
19-
20-
#endif // V8_INCLUDE_VERSION_H_
1+
// Copyright 2015 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
#ifndef V8_INCLUDE_VERSION_H_ // V8_VERSION_H_ conflicts with src/version.h
6+
#define V8_INCLUDE_VERSION_H_
7+
8+
// These macros define the version number for the current version.
9+
// NOTE these macros are used by some of the tool scripts and the build
10+
// system so their names cannot be changed without changing the scripts.
11+
#define V8_MAJOR_VERSION 6
12+
#define V8_MINOR_VERSION 0
13+
#define V8_BUILD_NUMBER 287
14+
#define V8_PATCH_LEVEL 53
15+
16+
// Use 1 for candidates and 0 otherwise.
17+
// (Boolean macro values are not supported by all preprocessors.)
18+
#define V8_IS_CANDIDATE_VERSION 0
19+
20+
#endif // V8_INCLUDE_VERSION_H_

doc/api/http2.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,6 +1118,8 @@ added: v8.4.0
11181118
* `headers` {[Headers Object][]}
11191119
* `options` {Object}
11201120
* `statCheck` {Function}
1121+
* `onError` {Function} Callback function invoked in the case of an
1122+
Error before send
11211123
* `getTrailers` {Function} Callback function invoked to collect trailer
11221124
headers.
11231125
* `offset` {number} The offset position at which to begin reading
@@ -1146,6 +1148,16 @@ server.on('stream', (stream) => {
11461148
function statCheck(stat, headers) {
11471149
headers['last-modified'] = stat.mtime.toUTCString();
11481150
}
1151+
1152+
function onError(err) {
1153+
if (err.code === 'ENOENT') {
1154+
stream.respond({ ':status': 404 });
1155+
} else {
1156+
stream.respond({ ':status': 500 });
1157+
}
1158+
stream.end();
1159+
}
1160+
11491161
stream.respondWithFile('/some/file',
11501162
{ 'content-type': 'text/plain' },
11511163
{ statCheck });
@@ -1178,6 +1190,10 @@ The `offset` and `length` options may be used to limit the response to a
11781190
specific range subset. This can be used, for instance, to support HTTP Range
11791191
requests.
11801192

1193+
The `options.onError` function may also be used to handle all the errors
1194+
that could happen before the delivery of the file is initiated. The
1195+
default behavior is to destroy the stream.
1196+
11811197
When set, the `options.getTrailers()` function is called immediately after
11821198
queuing the last chunk of payload data to be sent. The callback is passed a
11831199
single object (with a `null` prototype) that the listener may used to specify
@@ -1208,6 +1224,19 @@ added: v8.4.0
12081224

12091225
* Extends: {net.Server}
12101226

1227+
In `Http2Server`, there is no `'clientError'` event as there is in
1228+
HTTP1. However, there are `'socketError'`, `'sessionError'`, and
1229+
`'streamError'`, for error happened on the socket, session or stream
1230+
respectively.
1231+
1232+
#### Event: 'socketError'
1233+
<!-- YAML
1234+
added: v8.4.0
1235+
-->
1236+
1237+
The `'socketError'` event is emitted when a `'socketError'` event is emitted by
1238+
an `Http2Session` associated with the server.
1239+
12111240
#### Event: 'sessionError'
12121241
<!-- YAML
12131242
added: v8.4.0
@@ -1217,13 +1246,15 @@ The `'sessionError'` event is emitted when an `'error'` event is emitted by
12171246
an `Http2Session` object. If no listener is registered for this event, an
12181247
`'error'` event is emitted.
12191248

1220-
#### Event: 'socketError'
1249+
#### Event: 'streamError'
12211250
<!-- YAML
1222-
added: v8.4.0
1251+
added: REPLACEME
12231252
-->
12241253

1225-
The `'socketError'` event is emitted when a `'socketError'` event is emitted by
1226-
an `Http2Session` associated with the server.
1254+
* `socket` {http2.ServerHttp2Stream}
1255+
1256+
If an `ServerHttp2Stream` emits an `'error'` event, it will be forwarded here.
1257+
The stream will already be destroyed when this event is triggered.
12271258

12281259
#### Event: 'stream'
12291260
<!-- YAML

doc/api/perf_hooks.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
added: REPLACEME
44
-->
55

6+
> Stability: 1 - Experimental
7+
68
The Performance Timing API provides an implementation of the
79
[W3C Performance Timeline][] specification. The purpose of the API
810
is to support collection of high resolution performance metrics.

doc/api/stream.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,7 +894,7 @@ in object mode.
894894
The optional `size` argument specifies a specific number of bytes to read. If
895895
`size` bytes are not available to be read, `null` will be returned *unless*
896896
the stream has ended, in which case all of the data remaining in the internal
897-
buffer will be returned (*even if it exceeds `size` bytes*).
897+
buffer will be returned.
898898

899899
If the `size` argument is not specified, all of the data contained in the
900900
internal buffer will be returned.

lib/assert.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
'use strict';
2222

2323
const { compare } = process.binding('buffer');
24-
const util = require('util');
25-
const { isSet, isMap } = process.binding('util');
24+
const { isSet, isMap, isDate, isRegExp } = process.binding('util');
2625
const { objectToString } = require('internal/util');
2726
const errors = require('internal/errors');
2827

@@ -119,10 +118,9 @@ function areSimilarRegExps(a, b) {
119118
}
120119

121120
// For small buffers it's faster to compare the buffer in a loop. The c++
122-
// barrier including the Buffer.from operation takes the advantage of the faster
123-
// compare otherwise. 300 was the number after which compare became faster.
121+
// barrier including the Uint8Array operation takes the advantage of the faster
122+
// binary compare otherwise. The break even point was at about 300 characters.
124123
function areSimilarTypedArrays(a, b) {
125-
const { from } = require('buffer').Buffer;
126124
const len = a.byteLength;
127125
if (len !== b.byteLength) {
128126
return false;
@@ -135,8 +133,8 @@ function areSimilarTypedArrays(a, b) {
135133
}
136134
return true;
137135
}
138-
return compare(from(a.buffer, a.byteOffset, len),
139-
from(b.buffer, b.byteOffset, b.byteLength)) === 0;
136+
return compare(new Uint8Array(a.buffer, a.byteOffset, len),
137+
new Uint8Array(b.buffer, b.byteOffset, b.byteLength)) === 0;
140138
}
141139

142140
function isFloatTypedArrayTag(tag) {
@@ -190,11 +188,11 @@ function strictDeepEqual(actual, expected) {
190188
// Skip testing the part below and continue in the callee function.
191189
return;
192190
}
193-
if (util.isDate(actual)) {
191+
if (isDate(actual)) {
194192
if (actual.getTime() !== expected.getTime()) {
195193
return false;
196194
}
197-
} else if (util.isRegExp(actual)) {
195+
} else if (isRegExp(actual)) {
198196
if (!areSimilarRegExps(actual, expected)) {
199197
return false;
200198
}
@@ -223,10 +221,10 @@ function looseDeepEqual(actual, expected) {
223221
if (expected === null || typeof expected !== 'object') {
224222
return false;
225223
}
226-
if (util.isDate(actual) && util.isDate(expected)) {
224+
if (isDate(actual) && isDate(expected)) {
227225
return actual.getTime() === expected.getTime();
228226
}
229-
if (util.isRegExp(actual) && util.isRegExp(expected)) {
227+
if (isRegExp(actual) && isRegExp(expected)) {
230228
return areSimilarRegExps(actual, expected);
231229
}
232230
const actualTag = objectToString(actual);

lib/console.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ function Console(stdout, stderr, ignoreErrors = true) {
6161
Object.defineProperty(this, '_stderrErrorHandler', prop);
6262

6363
this[kCounts] = new Map();
64+
65+
Object.defineProperty(this, kGroupIndent, { writable: true });
6466
this[kGroupIndent] = '';
6567

6668
// bind the prototype functions to this Console instance
@@ -87,7 +89,15 @@ function createWriteErrorHandler(stream) {
8789
};
8890
}
8991

90-
function write(ignoreErrors, stream, string, errorhandler) {
92+
function write(ignoreErrors, stream, string, errorhandler, groupIndent) {
93+
if (groupIndent.length !== 0) {
94+
if (string.indexOf('\n') !== -1) {
95+
string = string.replace(/\n/g, `\n${groupIndent}`);
96+
}
97+
string = groupIndent + string;
98+
}
99+
string += '\n';
100+
91101
if (!ignoreErrors) return stream.write(string);
92102

93103
// There may be an error occurring synchronously (e.g. for files or TTYs
@@ -116,8 +126,9 @@ function write(ignoreErrors, stream, string, errorhandler) {
116126
Console.prototype.log = function log(...args) {
117127
write(this._ignoreErrors,
118128
this._stdout,
119-
`${this[kGroupIndent]}${util.format.apply(null, args)}\n`,
120-
this._stdoutErrorHandler);
129+
util.format.apply(null, args),
130+
this._stdoutErrorHandler,
131+
this[kGroupIndent]);
121132
};
122133

123134

@@ -127,8 +138,9 @@ Console.prototype.info = Console.prototype.log;
127138
Console.prototype.warn = function warn(...args) {
128139
write(this._ignoreErrors,
129140
this._stderr,
130-
`${this[kGroupIndent]}${util.format.apply(null, args)}\n`,
131-
this._stderrErrorHandler);
141+
util.format.apply(null, args),
142+
this._stderrErrorHandler,
143+
this[kGroupIndent]);
132144

133145
trace_mgr.emitTrace('emitOnLogWarn'); //ENABLE_TTD
134146
};
@@ -147,8 +159,9 @@ Console.prototype.dir = function dir(object, options) {
147159
options = Object.assign({ customInspect: false }, options);
148160
write(this._ignoreErrors,
149161
this._stdout,
150-
`${this[kGroupIndent]}${util.inspect(object, options)}\n`,
151-
this._stdoutErrorHandler);
162+
util.inspect(object, options),
163+
this._stdoutErrorHandler,
164+
this[kGroupIndent]);
152165
};
153166

154167

lib/http2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const {
1515
createSecureServer,
1616
connect,
1717
Http2ServerRequest,
18-
Http2ServerResponse,
18+
Http2ServerResponse
1919
} = require('internal/http2/core');
2020

2121
module.exports = {
@@ -27,5 +27,5 @@ module.exports = {
2727
createSecureServer,
2828
connect,
2929
Http2ServerResponse,
30-
Http2ServerRequest,
30+
Http2ServerRequest
3131
};

lib/internal/http2/compat.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,13 @@ function onStreamEnd() {
5858
}
5959

6060
function onStreamError(error) {
61-
const request = this[kRequest];
62-
request.emit('error', error);
61+
// this is purposefully left blank
62+
//
63+
// errors in compatibility mode are
64+
// not forwarded to the request
65+
// and response objects. However,
66+
// they are forwarded to 'clientError'
67+
// on the server by Http2Stream
6368
}
6469

6570
function onRequestPause() {
@@ -82,11 +87,6 @@ function onStreamResponseDrain() {
8287
response.emit('drain');
8388
}
8489

85-
function onStreamResponseError(error) {
86-
const response = this[kResponse];
87-
response.emit('error', error);
88-
}
89-
9090
function onStreamClosedRequest() {
9191
const req = this[kRequest];
9292
req.push(null);
@@ -271,9 +271,7 @@ class Http2ServerResponse extends Stream {
271271
stream[kResponse] = this;
272272
this.writable = true;
273273
stream.on('drain', onStreamResponseDrain);
274-
stream.on('error', onStreamResponseError);
275274
stream.on('close', onStreamClosedResponse);
276-
stream.on('aborted', onAborted.bind(this));
277275
const onfinish = this[kFinish].bind(this);
278276
stream.on('streamClosed', onfinish);
279277
stream.on('finish', onfinish);

0 commit comments

Comments
 (0)