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 3d53848 as of 2018-02-12
This commit was automatically generated. For any problems, please contact jackhorton

Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
  • Loading branch information
chakrabot committed Feb 14, 2018
2 parents 6e93807 + 3d53848 commit 65a249e
Show file tree
Hide file tree
Showing 36 changed files with 372 additions and 594 deletions.
6 changes: 3 additions & 3 deletions doc/api/async_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ and document their own resource objects. For example, such a resource object
could contain the SQL query being executed.

In the case of Promises, the `resource` object will have `promise` property
that refers to the Promise that is being initialized, and a `parentId` property
set to the `asyncId` of a parent Promise, if there is one, and `undefined`
that refers to the Promise that is being initialized, and a `isChainedPromise`
property, set to `true` if the promise has a parent promise, and `false`
otherwise. For example, in the case of `b = a.then(handler)`, `a` is considered
a parent Promise of `b`.
a parent Promise of `b`. Here, `b` is considered a chained promise.

In some cases the resource object is reused for performance reasons, it is
thus not safe to use it as a key in a `WeakMap` or add properties to it.
Expand Down
5 changes: 3 additions & 2 deletions doc/api/deprecations.md
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,10 @@ instead.
<a id="DEP0041"></a>
### DEP0041: NODE\_REPL\_HISTORY\_FILE environment variable

Type: Documentation-only
Type: End-of-life

The `NODE_REPL_HISTORY_FILE` environment variable has been deprecated.
The `NODE_REPL_HISTORY_FILE` environment variable was removed. Please use
`NODE_REPL_HISTORY` instead.

<a id="DEP0042"></a>
### DEP0042: tls.CryptoStream
Expand Down
3 changes: 0 additions & 3 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,6 @@ example `fs.readdirSync('c:\\')` can potentially return a different result than
<!-- YAML
added: v7.6.0
-->

> Stability: 1 - Experimental
For most `fs` module functions, the `path` or `filename` argument may be passed
as a WHATWG [`URL`][] object. Only [`URL`][] objects using the `file:` protocol
are supported.
Expand Down
16 changes: 0 additions & 16 deletions doc/api/repl.md
Original file line number Diff line number Diff line change
Expand Up @@ -506,22 +506,6 @@ by saving inputs to a `.node_repl_history` file located in the user's home
directory. This can be disabled by setting the environment variable
`NODE_REPL_HISTORY=""`.

#### NODE_REPL_HISTORY_FILE
<!-- YAML
added: v2.0.0
deprecated: v3.0.0
-->

> Stability: 0 - Deprecated: Use `NODE_REPL_HISTORY` instead.
Previously in Node.js/io.js v2.x, REPL history was controlled by using a
`NODE_REPL_HISTORY_FILE` environment variable, and the history was saved in JSON
format. This variable has now been deprecated, and the old JSON REPL history
file will be automatically converted to a simplified plain text format. This new
file will be saved to either the user's home directory, or a directory defined
by the `NODE_REPL_HISTORY` variable, as documented in the
[Environment Variable Options](#repl_environment_variable_options).

### Using the Node.js REPL with advanced line-editors

For advanced line-editors, start Node.js with the environment variable
Expand Down
2 changes: 1 addition & 1 deletion lib/async_hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ function showEmitBeforeAfterWarning() {
process.emitWarning(
'asyncResource.emitBefore and emitAfter are deprecated. Please use ' +
'asyncResource.runInAsyncScope instead',
'DeprecationWarning', 'DEP00XX');
'DeprecationWarning', 'DEP0098');
emitBeforeAfterWarning = false;
}
}
Expand Down
12 changes: 8 additions & 4 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ function createErrDiff(actual, expected, operator) {
var skipped = false;
const util = lazyUtil();
const actualLines = util
.inspect(actual, { compact: false }).split('\n');
.inspect(actual, { compact: false, customInspect: false }).split('\n');
const expectedLines = util
.inspect(expected, { compact: false }).split('\n');
.inspect(expected, { compact: false, customInspect: false }).split('\n');
const msg = `Input A expected to ${operator} input B:\n` +
`${green}+ expected${white} ${red}- actual${white}`;
const skippedMsg = ' ... Lines skipped';
Expand All @@ -184,6 +184,8 @@ function createErrDiff(actual, expected, operator) {
}
actualLines.pop();
expectedLines.pop();
if (actualLines.length === 0 || expectedLines.length === 0)
break;
a = actualLines[actualLines.length - 1];
b = expectedLines[expectedLines.length - 1];
}
Expand Down Expand Up @@ -308,8 +310,10 @@ class AssertionError extends Error {
} else if (errorDiff === 1) {
// In case the objects are equal but the operator requires unequal, show
// the first object and say A equals B
const res = util
.inspect(actual, { compact: false }).split('\n');
const res = util.inspect(
actual,
{ compact: false, customInspect: false }
).split('\n');

if (res.length > 20) {
res[19] = '...';
Expand Down
37 changes: 24 additions & 13 deletions lib/internal/http2/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1415,18 +1415,6 @@ function afterDoStreamWrite(status, handle, req) {
req.handle = undefined;
}

function onHandleFinish() {
const handle = this[kHandle];
if (this[kID] === undefined) {
this.once('ready', onHandleFinish);
} else if (handle !== undefined) {
const req = new ShutdownWrap();
req.oncomplete = () => {};
req.handle = handle;
handle.shutdown(req);
}
}

function streamOnResume() {
if (!this.destroyed && !this.pending)
this[kHandle].readStart();
Expand All @@ -1447,6 +1435,13 @@ function abort(stream) {
}
}

function afterShutdown() {
this.callback();
const stream = this.handle[kOwner];
if (stream)
stream[kMaybeDestroy]();
}

// An Http2Stream is a Duplex stream that is backed by a
// node::http2::Http2Stream handle implementing StreamBase.
class Http2Stream extends Duplex {
Expand All @@ -1471,7 +1466,6 @@ class Http2Stream extends Duplex {
writeQueueSize: 0
};

this.once('finish', onHandleFinish);
this.on('resume', streamOnResume);
this.on('pause', streamOnPause);
}
Expand Down Expand Up @@ -1678,6 +1672,23 @@ class Http2Stream extends Duplex {
trackWriteState(this, req.bytes);
}

_final(cb) {
const handle = this[kHandle];
if (this[kID] === undefined) {
this.once('ready', () => this._final(cb));
} else if (handle !== undefined) {
debug(`Http2Stream ${this[kID]} [Http2Session ` +
`${sessionName(this[kSession][kType])}]: _final shutting down`);
const req = new ShutdownWrap();
req.oncomplete = afterShutdown;
req.callback = cb;
req.handle = handle;
handle.shutdown(req);
} else {
cb();
}
}

_read(nread) {
if (this.destroyed) {
this.push(null);
Expand Down
62 changes: 9 additions & 53 deletions lib/internal/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const os = require('os');
const util = require('util');
const debug = util.debuglog('repl');
module.exports = Object.create(REPL);
module.exports.createInternalRepl = createInternalRepl;
module.exports.createInternalRepl = createRepl;

// XXX(chrisdickinson): The 15ms debounce value is somewhat arbitrary.
// The debounce is to guard against code pasted into the REPL.
Expand All @@ -19,7 +19,7 @@ function _writeToOutput(repl, message) {
repl._refreshLine();
}

function createInternalRepl(env, opts, cb) {
function createRepl(env, opts, cb) {
if (typeof opts === 'function') {
cb = opts;
opts = null;
Expand All @@ -34,7 +34,7 @@ function createInternalRepl(env, opts, cb) {
if (parseInt(env.NODE_NO_READLINE)) {
opts.terminal = false;
}
// the "dumb" special terminal, as defined by terminfo, doesn't support
// The "dumb" special terminal, as defined by terminfo, doesn't support
// ANSI color control codes.
// see http://invisible-island.net/ncurses/terminfo.ti.html#toc-_Specials
if (parseInt(env.NODE_DISABLE_COLORS) || env.TERM === 'dumb') {
Expand All @@ -61,17 +61,15 @@ function createInternalRepl(env, opts, cb) {

const repl = REPL.start(opts);
if (opts.terminal) {
return setupHistory(repl, env.NODE_REPL_HISTORY,
env.NODE_REPL_HISTORY_FILE, cb);
return setupHistory(repl, env.NODE_REPL_HISTORY, cb);
}

repl._historyPrev = _replHistoryMessage;
cb(null, repl);
}

function setupHistory(repl, historyPath, oldHistoryPath, ready) {
// Empty string disables persistent history.

function setupHistory(repl, historyPath, ready) {
// Empty string disables persistent history
if (typeof historyPath === 'string')
historyPath = historyPath.trim();

Expand Down Expand Up @@ -131,50 +129,8 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) {

if (data) {
repl.history = data.split(/[\n\r]+/, repl.historySize);
} else if (oldHistoryPath === historyPath) {
// If pre-v3.0, the user had set NODE_REPL_HISTORY_FILE to
// ~/.node_repl_history, warn the user about it and proceed.
_writeToOutput(
repl,
'\nThe old repl history file has the same name and location as ' +
`the new one i.e., ${historyPath} and is empty.\nUsing it as is.\n`);

} else if (oldHistoryPath) {
let threw = false;
try {
// Pre-v3.0, repl history was stored as JSON.
// Try and convert it to line separated history.
const oldReplJSONHistory = fs.readFileSync(oldHistoryPath, 'utf8');

// Only attempt to use the history if there was any.
if (oldReplJSONHistory) repl.history = JSON.parse(oldReplJSONHistory);

if (Array.isArray(repl.history)) {
repl.history = repl.history.slice(0, repl.historySize);
} else {
threw = true;
_writeToOutput(
repl,
'\nError: The old history file data has to be an Array.\n' +
'REPL session history will not be persisted.\n');
}
} catch (err) {
// Cannot open or parse history file.
// Don't crash, just don't persist history.
threw = true;
const type = err instanceof SyntaxError ? 'parse' : 'open';
_writeToOutput(repl, `\nError: Could not ${type} old history file.\n` +
'REPL session history will not be persisted.\n');
}
if (!threw) {
// Grab data from the older pre-v3.0 JSON NODE_REPL_HISTORY_FILE format.
_writeToOutput(
repl,
'\nConverted old JSON repl history to line-separated history.\n' +
`The new repl history file can be found at ${historyPath}.\n`);
} else {
repl.history = [];
}
} else {
repl.history = [];
}

fs.open(historyPath, 'r+', onhandle);
Expand All @@ -188,7 +144,7 @@ function setupHistory(repl, historyPath, oldHistoryPath, ready) {
repl._historyHandle = hnd;
repl.on('line', online);

// reading the file data out erases it
// Reading the file data out erases it
repl.once('flushHistory', function() {
repl.resume();
ready(null, repl);
Expand Down
Loading

0 comments on commit 65a249e

Please sign in to comment.