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

Commit

Permalink
meta: merge node/master into node-chakracore/master
Browse files Browse the repository at this point in the history
Merge 1385e1b as of 2018-01-12
This commit was automatically generated. For any problems, please contact jackhorton

Reviewed-By: Taylor Woll <tawoll@ntdev.microsoft.com>
  • Loading branch information
chakrabot committed Jan 21, 2018
2 parents 948537d + 1385e1b commit 0214db5
Show file tree
Hide file tree
Showing 23 changed files with 295 additions and 42 deletions.
23 changes: 20 additions & 3 deletions BUILDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Depending on host platform, the selection of toolchains may vary.

### Unix/macOS

Prerequisites:
#### Prerequisites

* `gcc` and `g++` 4.9.4 or newer, or
* `clang` and `clang++` 3.4.2 or newer (macOS: latest Xcode Command Line Tools)
Expand All @@ -120,6 +120,8 @@ directory and the symbolic `node` link in the project's root directory.
On FreeBSD and OpenBSD, you may also need:
* libexecinfo

#### Building Node.js

To build Node.js:

```console
Expand All @@ -138,13 +140,26 @@ for more information.
Note that the above requires that `python` resolve to Python 2.6 or 2.7
and not a newer version.

To run the tests:
#### Running Tests

To verify the build:

```console
$ make test-only
```

At this point, you are ready to make code changes and re-run the tests.

If you are running tests prior to submitting a Pull Request, the recommended
command is:

```console
$ make test
```

At this point you are ready to make code changes and re-run the tests!
`make test` does a full check on the codebase, including running linters and
documentation tests.

Optionally, continue below.

To run the tests and generate code coverage reports:
Expand All @@ -166,6 +181,8 @@ reports:
$ make coverage-clean
```

#### Building the documentation

To build the documentation:

This will build Node.js first (if necessary) and then use it to build the docs:
Expand Down
4 changes: 2 additions & 2 deletions doc/api/assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ added: v0.1.21
* `expected` {any}
* `message` {any} **Default:** `'Failed'`
* `operator` {string} **Default:** '!='
* `stackStartFunction` {function} **Default:** `assert.fail`
* `stackStartFunction` {Function} **Default:** `assert.fail`

Throws an `AssertionError`. If `message` is falsy, the error message is set as
the values of `actual` and `expected` separated by the provided `operator`. If
Expand Down Expand Up @@ -719,7 +719,7 @@ changes:
description: The `error` parameter can now be an arrow function.
-->
* `block` {Function}
* `error` {RegExp|Function|object}
* `error` {RegExp|Function|Object}
* `message` {any}

Expects the function `block` to throw an error.
Expand Down
2 changes: 1 addition & 1 deletion doc/api/cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ changes:
`'ipc'` entry. When this option is provided, it overrides `silent`.
* `uid` {number} Sets the user identity of the process. (See setuid(2).)
* `gid` {number} Sets the group identity of the process. (See setgid(2).)
* `inspectPort` {number|function} Sets inspector port of worker.
* `inspectPort` {number|Function} Sets inspector port of worker.
This can be a number, or a function that takes no arguments and returns a
number. By default each worker gets its own port, incremented from the
master's `process.debugPort`.
Expand Down
4 changes: 2 additions & 2 deletions doc/api/dgram.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ added: v0.11.14
-->

* `options` {Object} Required. Supports the following properties:
* `port` {Integer}
* `port` {integer}
* `address` {string}
* `exclusive` {boolean}
* `callback` {Function}
Expand Down Expand Up @@ -390,7 +390,7 @@ packets may be sent to a local interface's broadcast address.
added: v8.6.0
-->

* `multicastInterface` {String}
* `multicastInterface` {string}

*Note: All references to scope in this section are referring to
[IPv6 Zone Indices][], which are defined by [RFC 4007][]. In string form, an IP
Expand Down
2 changes: 1 addition & 1 deletion doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1334,7 +1334,7 @@ deprecated: v1.0.0
* `path` {string|Buffer|URL}
* `callback` {Function}
* `exists` {Boolean}
* `exists` {boolean}

Test whether or not the given path exists by checking with the file system.
Then call the `callback` argument with either true or false. Example:
Expand Down
38 changes: 34 additions & 4 deletions doc/api/http2.md
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,34 @@ destroyed after either receiving an `RST_STREAM` frame from the connected peer,
calling `http2stream.close()`, or `http2stream.destroy()`. Will be
`undefined` if the `Http2Stream` has not been closed.

#### http2stream.sentHeaders
<!-- YAML
added: REPLACEME
-->

* Value: {[Headers Object][]}

An object containing the outbound headers sent for this `Http2Stream`.

#### http2stream.sentInfoHeaders
<!-- YAML
added: REPLACEME
-->

* Value: {[Headers Object][]\[\]}

An array of objects containing the outbound informational (additional) headers
sent for this `Http2Stream`.

#### http2stream.sentTrailers
<!-- YAML
added: REPLACEME
-->

* Value: {[Headers Object][]}

An object containing the outbound trailers sent for this this `HttpStream`.

#### http2stream.session
<!-- YAML
added: v8.4.0
Expand All @@ -1015,7 +1043,7 @@ const { NGHTTP2_CANCEL } = http2.constants;
const req = client.request({ ':path': '/' });

// Cancel the stream if there's no activity after 5 seconds
req.setTimeout(5000, () => req.rstStream(NGHTTP2_CANCEL));
req.setTimeout(5000, () => req.close(NGHTTP2_CANCEL));
```

#### http2stream.state
Expand Down Expand Up @@ -1174,14 +1202,16 @@ added: v8.4.0
* Returns: {undefined}

Initiates a push stream. The callback is invoked with the new `Http2Stream`
instance created for the push stream.
instance created for the push stream passed as the second argument, or an
`Error` passed as the first argument.

```js
const http2 = require('http2');
const server = http2.createServer();
server.on('stream', (stream) => {
stream.respond({ ':status': 200 });
stream.pushStream({ ':path': '/' }, (pushStream) => {
stream.pushStream({ ':path': '/' }, (err, pushStream) => {
if (err) throw err;
pushStream.respond({ ':status': 200 });
pushStream.end('some pushed data');
});
Expand All @@ -1202,7 +1232,7 @@ added: v8.4.0
* `options` {Object}
* `endStream` {boolean} Set to `true` to indicate that the response will not
include payload data.
* `getTrailers` {function} Callback function invoked to collect trailer
* `getTrailers` {Function} Callback function invoked to collect trailer
headers.
* Returns: {undefined}

Expand Down
2 changes: 1 addition & 1 deletion doc/api/net.md
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ server.listen({
added: v0.1.90
-->

* `path` {String} Path the server should listen to. See
* `path` {string} Path the server should listen to. See
[Identifying paths for IPC connections][].
* `backlog` {number} Common parameter of [`server.listen()`][] functions.
* `callback` {Function} Common parameter of [`server.listen()`][] functions.
Expand Down
8 changes: 8 additions & 0 deletions doc/api/perf_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ added: v8.5.0
The `Performance` provides access to performance metric data. A single
instance of this class is provided via the `performance` property.

### performance.clearEntries(name)
<!-- YAML
added: REPLACEME
-->

Remove all performance entry objects with `entryType` equal to `name` from the
Performance Timeline.

### performance.clearFunctions([name])
<!-- YAML
added: v8.5.0
Expand Down
16 changes: 8 additions & 8 deletions doc/guides/using-internal-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ likely be required.

### Class: errors.Error(key[, args...])

* `key` {String} The static error identifier
* `args...` {Any} Zero or more optional arguments
* `key` {string} The static error identifier
* `args...` {any} Zero or more optional arguments

```js
const errors = require('internal/errors');
Expand All @@ -139,8 +139,8 @@ The `myError` object will have a `code` property equal to the `key` and a

### Class: errors.TypeError(key[, args...])

* `key` {String} The static error identifier
* `args...` {Any} Zero or more optional arguments
* `key` {string} The static error identifier
* `args...` {any} Zero or more optional arguments

```js
const errors = require('internal/errors');
Expand All @@ -159,8 +159,8 @@ The `myError` object will have a `code` property equal to the `key` and a

### Class: errors.RangeError(key[, args...])

* `key` {String} The static error identifier
* `args...` {Any} Zero or more optional arguments
* `key` {string} The static error identifier
* `args...` {any} Zero or more optional arguments

```js
const errors = require('internal/errors');
Expand All @@ -179,8 +179,8 @@ The `myError` object will have a `code` property equal to the `key` and a

### Method: errors.message(key, args)

* `key` {String} The static error identifier
* `key` {string} The static error identifier
* `args` {Array} Zero or more optional arguments passed as an Array
* Returns: {String}
* Returns: {string}

Returns the formatted error message string for the given `key`.
28 changes: 19 additions & 9 deletions lib/_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ const {
} = require('_http_common');
const { OutgoingMessage } = require('_http_outgoing');
const { outHeadersKey, ondrain } = require('internal/http');
const {
defaultTriggerAsyncIdScope,
getOrSetAsyncId
} = require('internal/async_hooks');
const errors = require('internal/errors');
const Buffer = require('buffer').Buffer;

Expand Down Expand Up @@ -292,20 +296,26 @@ Server.prototype.setTimeout = function setTimeout(msecs, callback) {


function connectionListener(socket) {
defaultTriggerAsyncIdScope(
getOrSetAsyncId(socket), connectionListenerInternal, this, socket
);
}

function connectionListenerInternal(server, socket) {
debug('SERVER new http connection');

httpSocketSetup(socket);

// Ensure that the server property of the socket is correctly set.
// See https://github.com/nodejs/node/issues/13435
if (socket.server === null)
socket.server = this;
socket.server = server;

// If the user has added a listener to the server,
// request, or response, then it's their responsibility.
// otherwise, destroy on timeout by default
if (this.timeout && typeof socket.setTimeout === 'function')
socket.setTimeout(this.timeout);
if (server.timeout && typeof socket.setTimeout === 'function')
socket.setTimeout(server.timeout);
socket.on('timeout', socketOnTimeout);

var parser = parsers.alloc();
Expand All @@ -315,8 +325,8 @@ function connectionListener(socket) {
parser.incoming = null;

// Propagate headers limit from server instance to parser
if (typeof this.maxHeadersCount === 'number') {
parser.maxHeaderPairs = this.maxHeadersCount << 1;
if (typeof server.maxHeadersCount === 'number') {
parser.maxHeaderPairs = server.maxHeadersCount << 1;
} else {
// Set default value because parser may be reused from FreeList
parser.maxHeaderPairs = 2000;
Expand All @@ -336,16 +346,16 @@ function connectionListener(socket) {
outgoingData: 0,
keepAliveTimeoutSet: false
};
state.onData = socketOnData.bind(undefined, this, socket, parser, state);
state.onEnd = socketOnEnd.bind(undefined, this, socket, parser, state);
state.onData = socketOnData.bind(undefined, server, socket, parser, state);
state.onEnd = socketOnEnd.bind(undefined, server, socket, parser, state);
state.onClose = socketOnClose.bind(undefined, socket, state);
state.onDrain = socketOnDrain.bind(undefined, socket, state);
socket.on('data', state.onData);
socket.on('error', socketOnError);
socket.on('end', state.onEnd);
socket.on('close', state.onClose);
socket.on('drain', state.onDrain);
parser.onIncoming = parserOnIncoming.bind(undefined, this, socket, state);
parser.onIncoming = parserOnIncoming.bind(undefined, server, socket, state);

// We are consuming socket, so it won't get any actual data
socket.on('resume', onSocketResume);
Expand All @@ -364,7 +374,7 @@ function connectionListener(socket) {
}
}
parser[kOnExecute] =
onParserExecute.bind(undefined, this, socket, parser, state);
onParserExecute.bind(undefined, server, socket, parser, state);

socket._paused = false;
}
Expand Down
12 changes: 11 additions & 1 deletion lib/internal/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const async_wrap = process.binding('async_wrap');
* It has a fixed size, so if that is exceeded, calls to the native
* side are used instead in pushAsyncIds() and popAsyncIds().
*/
const { async_hook_fields, async_id_fields } = async_wrap;
const { async_id_symbol, async_hook_fields, async_id_fields } = async_wrap;
// Store the pair executionAsyncId and triggerAsyncId in a std::stack on
// Environment::AsyncHooks::ids_stack_ tracks the resource responsible for the
// current execution stack. This is unwound as each resource exits. In the case
Expand Down Expand Up @@ -248,6 +248,15 @@ function newUid() {
return ++async_id_fields[kAsyncIdCounter];
}

function getOrSetAsyncId(object) {
if (object.hasOwnProperty(async_id_symbol)) {
return object[async_id_symbol];
}

return object[async_id_symbol] = newUid();
}


// Return the triggerAsyncId meant for the constructor calling it. It's up to
// the user to safeguard this call and make sure it's zero'd out when the
// constructor is complete.
Expand Down Expand Up @@ -378,6 +387,7 @@ module.exports = {
disableHooks,
// Internal Embedder API
newUid,
getOrSetAsyncId,
getDefaultTriggerAsyncId,
defaultTriggerAsyncIdScope,
emitInit: emitInitScript,
Expand Down
Loading

0 comments on commit 0214db5

Please sign in to comment.