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

Commit

Permalink
Merge nodejs/master
Browse files Browse the repository at this point in the history
Merge 99c478e as of 2017-08-26.
This is an automatically created merge. For any problems please
contact @kunalspathak.
  • Loading branch information
chakrabot committed Sep 5, 2017
2 parents 094ccb1 + 99c478e commit 65cc69d
Show file tree
Hide file tree
Showing 20 changed files with 462 additions and 105 deletions.
8 changes: 4 additions & 4 deletions benchmark/dns/lookup.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ const lookup = require('dns').lookup;

const bench = common.createBenchmark(main, {
name: ['', '127.0.0.1', '::1'],
all: [true, false],
all: ['true', 'false'],
n: [5e6]
});

function main(conf) {
const name = conf.name;
const n = +conf.n;
const all = !!conf.all;
const all = conf.all === 'true' ? true : false;
var i = 0;

if (all) {
const opts = { all: true };
bench.start();
(function cb(err, results) {
(function cb() {
if (i++ === n) {
bench.end(n);
return;
Expand All @@ -27,7 +27,7 @@ function main(conf) {
})();
} else {
bench.start();
(function cb(err, result) {
(function cb() {
if (i++ === n) {
bench.end(n);
return;
Expand Down
40 changes: 20 additions & 20 deletions deps/chakrashim/include/v8-version.h
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_INCLUDE_VERSION_H_ // V8_VERSION_H_ conflicts with src/version.h
#define V8_INCLUDE_VERSION_H_

// These macros define the version number for the current version.
// NOTE these macros are used by some of the tool scripts and the build
// system so their names cannot be changed without changing the scripts.
#define V8_MAJOR_VERSION 6
#define V8_MINOR_VERSION 0
#define V8_BUILD_NUMBER 287
#define V8_PATCH_LEVEL 53

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define V8_IS_CANDIDATE_VERSION 0

#endif // V8_INCLUDE_VERSION_H_
// Copyright 2015 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_INCLUDE_VERSION_H_ // V8_VERSION_H_ conflicts with src/version.h
#define V8_INCLUDE_VERSION_H_

// These macros define the version number for the current version.
// NOTE these macros are used by some of the tool scripts and the build
// system so their names cannot be changed without changing the scripts.
#define V8_MAJOR_VERSION 6
#define V8_MINOR_VERSION 0
#define V8_BUILD_NUMBER 287
#define V8_PATCH_LEVEL 53

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
#define V8_IS_CANDIDATE_VERSION 0

#endif // V8_INCLUDE_VERSION_H_
39 changes: 35 additions & 4 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -1118,6 +1118,8 @@ added: v8.4.0
* `headers` {[Headers Object][]}
* `options` {Object}
* `statCheck` {Function}
* `onError` {Function} Callback function invoked in the case of an
Error before send
* `getTrailers` {Function} Callback function invoked to collect trailer
headers.
* `offset` {number} The offset position at which to begin reading
Expand Down Expand Up @@ -1146,6 +1148,16 @@ server.on('stream', (stream) => {
function statCheck(stat, headers) {
headers['last-modified'] = stat.mtime.toUTCString();
}

function onError(err) {
if (err.code === 'ENOENT') {
stream.respond({ ':status': 404 });
} else {
stream.respond({ ':status': 500 });
}
stream.end();
}

stream.respondWithFile('/some/file',
{ 'content-type': 'text/plain' },
{ statCheck });
Expand Down Expand Up @@ -1178,6 +1190,10 @@ The `offset` and `length` options may be used to limit the response to a
specific range subset. This can be used, for instance, to support HTTP Range
requests.

The `options.onError` function may also be used to handle all the errors
that could happen before the delivery of the file is initiated. The
default behavior is to destroy the stream.

When set, the `options.getTrailers()` function is called immediately after
queuing the last chunk of payload data to be sent. The callback is passed a
single object (with a `null` prototype) that the listener may used to specify
Expand Down Expand Up @@ -1208,6 +1224,19 @@ added: v8.4.0

* Extends: {net.Server}

In `Http2Server`, there is no `'clientError'` event as there is in
HTTP1. However, there are `'socketError'`, `'sessionError'`, and
`'streamError'`, for error happened on the socket, session or stream
respectively.

#### Event: 'socketError'
<!-- YAML
added: v8.4.0
-->

The `'socketError'` event is emitted when a `'socketError'` event is emitted by
an `Http2Session` associated with the server.

#### Event: 'sessionError'
<!-- YAML
added: v8.4.0
Expand All @@ -1217,13 +1246,15 @@ The `'sessionError'` event is emitted when an `'error'` event is emitted by
an `Http2Session` object. If no listener is registered for this event, an
`'error'` event is emitted.

#### Event: 'socketError'
#### Event: 'streamError'
<!-- YAML
added: v8.4.0
added: REPLACEME
-->

The `'socketError'` event is emitted when a `'socketError'` event is emitted by
an `Http2Session` associated with the server.
* `socket` {http2.ServerHttp2Stream}

If an `ServerHttp2Stream` emits an `'error'` event, it will be forwarded here.
The stream will already be destroyed when this event is triggered.

#### Event: 'stream'
<!-- YAML
Expand Down
2 changes: 2 additions & 0 deletions doc/api/perf_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
added: REPLACEME
-->

> Stability: 1 - Experimental
The Performance Timing API provides an implementation of the
[W3C Performance Timeline][] specification. The purpose of the API
is to support collection of high resolution performance metrics.
Expand Down
2 changes: 1 addition & 1 deletion doc/api/stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ in object mode.
The optional `size` argument specifies a specific number of bytes to read. If
`size` bytes are not available to be read, `null` will be returned *unless*
the stream has ended, in which case all of the data remaining in the internal
buffer will be returned (*even if it exceeds `size` bytes*).
buffer will be returned.

If the `size` argument is not specified, all of the data contained in the
internal buffer will be returned.
Expand Down
20 changes: 9 additions & 11 deletions lib/assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
'use strict';

const { compare } = process.binding('buffer');
const util = require('util');
const { isSet, isMap } = process.binding('util');
const { isSet, isMap, isDate, isRegExp } = process.binding('util');
const { objectToString } = require('internal/util');
const errors = require('internal/errors');

Expand Down Expand Up @@ -119,10 +118,9 @@ function areSimilarRegExps(a, b) {
}

// For small buffers it's faster to compare the buffer in a loop. The c++
// barrier including the Buffer.from operation takes the advantage of the faster
// compare otherwise. 300 was the number after which compare became faster.
// barrier including the Uint8Array operation takes the advantage of the faster
// binary compare otherwise. The break even point was at about 300 characters.
function areSimilarTypedArrays(a, b) {
const { from } = require('buffer').Buffer;
const len = a.byteLength;
if (len !== b.byteLength) {
return false;
Expand All @@ -135,8 +133,8 @@ function areSimilarTypedArrays(a, b) {
}
return true;
}
return compare(from(a.buffer, a.byteOffset, len),
from(b.buffer, b.byteOffset, b.byteLength)) === 0;
return compare(new Uint8Array(a.buffer, a.byteOffset, len),
new Uint8Array(b.buffer, b.byteOffset, b.byteLength)) === 0;
}

function isFloatTypedArrayTag(tag) {
Expand Down Expand Up @@ -190,11 +188,11 @@ function strictDeepEqual(actual, expected) {
// Skip testing the part below and continue in the callee function.
return;
}
if (util.isDate(actual)) {
if (isDate(actual)) {
if (actual.getTime() !== expected.getTime()) {
return false;
}
} else if (util.isRegExp(actual)) {
} else if (isRegExp(actual)) {
if (!areSimilarRegExps(actual, expected)) {
return false;
}
Expand Down Expand Up @@ -223,10 +221,10 @@ function looseDeepEqual(actual, expected) {
if (expected === null || typeof expected !== 'object') {
return false;
}
if (util.isDate(actual) && util.isDate(expected)) {
if (isDate(actual) && isDate(expected)) {
return actual.getTime() === expected.getTime();
}
if (util.isRegExp(actual) && util.isRegExp(expected)) {
if (isRegExp(actual) && isRegExp(expected)) {
return areSimilarRegExps(actual, expected);
}
const actualTag = objectToString(actual);
Expand Down
27 changes: 20 additions & 7 deletions lib/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ function Console(stdout, stderr, ignoreErrors = true) {
Object.defineProperty(this, '_stderrErrorHandler', prop);

this[kCounts] = new Map();

Object.defineProperty(this, kGroupIndent, { writable: true });
this[kGroupIndent] = '';

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

function write(ignoreErrors, stream, string, errorhandler) {
function write(ignoreErrors, stream, string, errorhandler, groupIndent) {
if (groupIndent.length !== 0) {
if (string.indexOf('\n') !== -1) {
string = string.replace(/\n/g, `\n${groupIndent}`);
}
string = groupIndent + string;
}
string += '\n';

if (!ignoreErrors) return stream.write(string);

// There may be an error occurring synchronously (e.g. for files or TTYs
Expand Down Expand Up @@ -116,8 +126,9 @@ function write(ignoreErrors, stream, string, errorhandler) {
Console.prototype.log = function log(...args) {
write(this._ignoreErrors,
this._stdout,
`${this[kGroupIndent]}${util.format.apply(null, args)}\n`,
this._stdoutErrorHandler);
util.format.apply(null, args),
this._stdoutErrorHandler,
this[kGroupIndent]);
};


Expand All @@ -127,8 +138,9 @@ Console.prototype.info = Console.prototype.log;
Console.prototype.warn = function warn(...args) {
write(this._ignoreErrors,
this._stderr,
`${this[kGroupIndent]}${util.format.apply(null, args)}\n`,
this._stderrErrorHandler);
util.format.apply(null, args),
this._stderrErrorHandler,
this[kGroupIndent]);

trace_mgr.emitTrace('emitOnLogWarn'); //ENABLE_TTD
};
Expand All @@ -147,8 +159,9 @@ Console.prototype.dir = function dir(object, options) {
options = Object.assign({ customInspect: false }, options);
write(this._ignoreErrors,
this._stdout,
`${this[kGroupIndent]}${util.inspect(object, options)}\n`,
this._stdoutErrorHandler);
util.inspect(object, options),
this._stdoutErrorHandler,
this[kGroupIndent]);
};


Expand Down
4 changes: 2 additions & 2 deletions lib/http2.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const {
createSecureServer,
connect,
Http2ServerRequest,
Http2ServerResponse,
Http2ServerResponse
} = require('internal/http2/core');

module.exports = {
Expand All @@ -27,5 +27,5 @@ module.exports = {
createSecureServer,
connect,
Http2ServerResponse,
Http2ServerRequest,
Http2ServerRequest
};
16 changes: 7 additions & 9 deletions lib/internal/http2/compat.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,13 @@ function onStreamEnd() {
}

function onStreamError(error) {
const request = this[kRequest];
request.emit('error', error);
// this is purposefully left blank
//
// errors in compatibility mode are
// not forwarded to the request
// and response objects. However,
// they are forwarded to 'clientError'
// on the server by Http2Stream
}

function onRequestPause() {
Expand All @@ -82,11 +87,6 @@ function onStreamResponseDrain() {
response.emit('drain');
}

function onStreamResponseError(error) {
const response = this[kResponse];
response.emit('error', error);
}

function onStreamClosedRequest() {
const req = this[kRequest];
req.push(null);
Expand Down Expand Up @@ -271,9 +271,7 @@ class Http2ServerResponse extends Stream {
stream[kResponse] = this;
this.writable = true;
stream.on('drain', onStreamResponseDrain);
stream.on('error', onStreamResponseError);
stream.on('close', onStreamClosedResponse);
stream.on('aborted', onAborted.bind(this));
const onfinish = this[kFinish].bind(this);
stream.on('streamClosed', onfinish);
stream.on('finish', onfinish);
Expand Down
Loading

0 comments on commit 65cc69d

Please sign in to comment.