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

Commit 1615778

Browse files
committed
meta: merge node/master into node-chakracore/master
Merge 0300565 as of 2017-11-06 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: Jack Horton <[email protected]>
2 parents a9a7dd0 + 0300565 commit 1615778

File tree

285 files changed

+9461
-8909
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

285 files changed

+9461
-8909
lines changed

doc/api/errors.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,11 @@ more headers.
754754
Used when an invalid character is found in an HTTP response status message
755755
(reason phrase).
756756

757+
<a id="ERR_HTTP_INVALID_HEADER_VALUE"></a>
758+
### ERR_HTTP_INVALID_HEADER_VALUE
759+
760+
Used to indicate that an invalid HTTP header value has been specified.
761+
757762
<a id="ERR_HTTP_INVALID_STATUS_CODE"></a>
758763
### ERR_HTTP_INVALID_STATUS_CODE
759764

@@ -837,7 +842,7 @@ requests and responses.
837842
<a id="ERR_HTTP2_INVALID_HEADER_VALUE"></a>
838843
### ERR_HTTP2_INVALID_HEADER_VALUE
839844

840-
Used to indicate that an invalid HTTP/2 header value has been specified.
845+
Used to indicate that an invalid HTTP2 header value has been specified.
841846

842847
<a id="ERR_HTTP2_INVALID_INFO_STATUS"></a>
843848
### ERR_HTTP2_INVALID_INFO_STATUS

doc/api/events.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ myEmitter.emit('event', 'a', 'b');
7777

7878
## Asynchronous vs. Synchronous
7979

80-
The `EventListener` calls all listeners synchronously in the order in which
80+
The `EventEmitter` calls all listeners synchronously in the order in which
8181
they were registered. This is important to ensure the proper sequencing of
8282
events and to avoid race conditions or logic errors. When appropriate,
8383
listener functions can switch to an asynchronous mode of operation using
@@ -268,7 +268,7 @@ property can be used. If this value is not a positive number, a `TypeError`
268268
will be thrown.
269269

270270
Take caution when setting the `EventEmitter.defaultMaxListeners` because the
271-
change effects *all* `EventEmitter` instances, including those created before
271+
change affects *all* `EventEmitter` instances, including those created before
272272
the change is made. However, calling [`emitter.setMaxListeners(n)`][] still has
273273
precedence over `EventEmitter.defaultMaxListeners`.
274274

doc/api/stream.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ reader.pipe(writer);
316316
added: v0.9.4
317317
-->
318318

319-
* `src` {[Readable][] Stream} The source stream that
319+
* `src` {stream.Readable} The source stream that
320320
[unpiped][`stream.unpipe()`] this writable
321321

322322
The `'unpipe'` event is emitted when the [`stream.unpipe()`][] method is called

lib/_http_outgoing.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -437,16 +437,7 @@ function _storeHeader(firstLine, headers) {
437437

438438
function storeHeader(self, state, key, value, validate) {
439439
if (validate) {
440-
if (typeof key !== 'string' || !key || !checkIsHttpToken(key)) {
441-
throw new errors.TypeError(
442-
'ERR_INVALID_HTTP_TOKEN', 'Header name', key);
443-
}
444-
if (value === undefined) {
445-
throw new errors.TypeError('ERR_MISSING_ARGS', `header "${key}"`);
446-
} else if (checkInvalidHeaderChar(value)) {
447-
debug('Header "%s" contains invalid characters', key);
448-
throw new errors.TypeError('ERR_INVALID_CHAR', 'header content', key);
449-
}
440+
validateHeader(key, value);
450441
}
451442
state.header += key + ': ' + escapeHeaderValue(value) + CRLF;
452443
matchHeader(self, state, key, value);
@@ -494,20 +485,27 @@ function matchHeader(self, state, field, value) {
494485
}
495486
}
496487

497-
function validateHeader(msg, name, value) {
498-
if (typeof name !== 'string' || !name || !checkIsHttpToken(name))
499-
throw new errors.TypeError('ERR_INVALID_HTTP_TOKEN', 'Header name', name);
500-
if (value === undefined)
501-
throw new errors.TypeError('ERR_MISSING_ARGS', 'value');
502-
if (msg._header)
503-
throw new errors.Error('ERR_HTTP_HEADERS_SENT', 'set');
504-
if (checkInvalidHeaderChar(value)) {
488+
function validateHeader(name, value) {
489+
let err;
490+
if (typeof name !== 'string' || !name || !checkIsHttpToken(name)) {
491+
err = new errors.TypeError('ERR_INVALID_HTTP_TOKEN', 'Header name', name);
492+
} else if (value === undefined) {
493+
err = new errors.TypeError('ERR_HTTP_INVALID_HEADER_VALUE', value, name);
494+
} else if (checkInvalidHeaderChar(value)) {
505495
debug('Header "%s" contains invalid characters', name);
506-
throw new errors.TypeError('ERR_INVALID_CHAR', 'header content', name);
496+
err = new errors.TypeError('ERR_INVALID_CHAR', 'header content', name);
497+
}
498+
if (err !== undefined) {
499+
Error.captureStackTrace(err, validateHeader);
500+
throw err;
507501
}
508502
}
503+
509504
OutgoingMessage.prototype.setHeader = function setHeader(name, value) {
510-
validateHeader(this, name, value);
505+
if (this._header) {
506+
throw new errors.Error('ERR_HTTP_HEADERS_SENT', 'set');
507+
}
508+
validateHeader(name, value);
511509

512510
if (!this[outHeadersKey])
513511
this[outHeadersKey] = {};

lib/internal/errors.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ E('ERR_HTTP2_INFO_STATUS_NOT_ALLOWED',
280280
'Informational status codes cannot be used');
281281
E('ERR_HTTP2_INVALID_CONNECTION_HEADERS',
282282
'HTTP/1 Connection specific headers are forbidden: "%s"');
283-
E('ERR_HTTP2_INVALID_HEADER_VALUE', 'Value must not be undefined or null');
283+
E('ERR_HTTP2_INVALID_HEADER_VALUE', 'Invalid value "%s" for header "%s"');
284284
E('ERR_HTTP2_INVALID_INFO_STATUS',
285285
(code) => `Invalid informational status code: ${code}`);
286286
E('ERR_HTTP2_INVALID_PACKED_SETTINGS_LENGTH',
@@ -317,6 +317,7 @@ E('ERR_HTTP2_UNSUPPORTED_PROTOCOL',
317317
E('ERR_HTTP_HEADERS_SENT',
318318
'Cannot %s headers after they are sent to the client');
319319
E('ERR_HTTP_INVALID_CHAR', 'Invalid character in statusMessage.');
320+
E('ERR_HTTP_INVALID_HEADER_VALUE', 'Invalid value "%s" for header "%s"');
320321
E('ERR_HTTP_INVALID_STATUS_CODE',
321322
(originalStatusCode) => `Invalid status code: ${originalStatusCode}`);
322323
E('ERR_HTTP_TRAILER_INVALID',

lib/internal/http2/compat.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ let statusMessageWarned = false;
4040
// close as possible to the current require('http') API
4141

4242
function assertValidHeader(name, value) {
43-
if (name === '' || typeof name !== 'string')
44-
throw new errors.TypeError('ERR_INVALID_HTTP_TOKEN', 'Header name', name);
45-
if (isPseudoHeader(name))
46-
throw new errors.Error('ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED');
47-
if (value === undefined || value === null)
48-
throw new errors.TypeError('ERR_HTTP2_INVALID_HEADER_VALUE');
43+
let err;
44+
if (name === '' || typeof name !== 'string') {
45+
err = new errors.TypeError('ERR_INVALID_HTTP_TOKEN', 'Header name', name);
46+
} else if (isPseudoHeader(name)) {
47+
err = new errors.Error('ERR_HTTP2_PSEUDOHEADER_NOT_ALLOWED');
48+
} else if (value === undefined || value === null) {
49+
err = new errors.TypeError('ERR_HTTP2_INVALID_HEADER_VALUE', value, name);
50+
}
51+
if (err !== undefined) {
52+
Error.captureStackTrace(err, assertValidHeader);
53+
throw err;
54+
}
4955
}
5056

5157
function isPseudoHeader(name) {

src/inspector_agent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#endif
1111

1212
#include "node_debug_options.h"
13+
#include "node_platform.h"
1314
#include "v8.h"
1415

1516
namespace v8_inspector {
@@ -19,7 +20,6 @@ class StringView;
1920
namespace node {
2021
// Forward declaration to break recursive dependency chain with src/env.h.
2122
class Environment;
22-
class NodePlatform;
2323

2424
namespace inspector {
2525

src/module_wrap.cc

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -310,17 +310,21 @@ std::string ReadFile(uv_file file) {
310310
uv_fs_t req;
311311
char buffer_memory[4096];
312312
uv_buf_t buf = uv_buf_init(buffer_memory, sizeof(buffer_memory));
313+
int r;
314+
313315
do {
314-
uv_fs_read(uv_default_loop(),
315-
&req,
316-
file,
317-
&buf,
318-
1,
319-
contents.length(), // offset
320-
nullptr);
321-
if (req.result <= 0)
316+
r = uv_fs_read(uv_default_loop(),
317+
&req,
318+
file,
319+
&buf,
320+
1,
321+
contents.length(), // offset
322+
nullptr);
323+
uv_fs_req_cleanup(&req);
324+
325+
if (r <= 0)
322326
break;
323-
contents.append(buf.base, req.result);
327+
contents.append(buf.base, r);
324328
} while (true);
325329
return contents;
326330
}
@@ -337,20 +341,29 @@ Maybe<uv_file> CheckFile(const URL& search,
337341
if (path.empty()) {
338342
return Nothing<uv_file>();
339343
}
340-
uv_fs_open(nullptr, &fs_req, path.c_str(), O_RDONLY, 0, nullptr);
341-
uv_file fd = fs_req.result;
344+
345+
uv_file fd = uv_fs_open(nullptr, &fs_req, path.c_str(), O_RDONLY, 0, nullptr);
346+
uv_fs_req_cleanup(&fs_req);
347+
342348
if (fd < 0) {
343349
return Nothing<uv_file>();
344350
}
345351

346352
uv_fs_fstat(nullptr, &fs_req, fd, nullptr);
347-
if (fs_req.statbuf.st_mode & S_IFDIR) {
353+
uint64_t is_directory = fs_req.statbuf.st_mode & S_IFDIR;
354+
uv_fs_req_cleanup(&fs_req);
355+
356+
if (is_directory) {
348357
uv_fs_close(nullptr, &fs_req, fd, nullptr);
358+
uv_fs_req_cleanup(&fs_req);
349359
return Nothing<uv_file>();
350360
}
351361

352-
if (opt == CLOSE_AFTER_CHECK)
362+
if (opt == CLOSE_AFTER_CHECK) {
353363
uv_fs_close(nullptr, &fs_req, fd, nullptr);
364+
uv_fs_req_cleanup(&fs_req);
365+
}
366+
354367
return Just(fd);
355368
}
356369

@@ -395,6 +408,7 @@ Maybe<URL> ResolveMain(Environment* env, const URL& search) {
395408
std::string pkg_src = ReadFile(check.FromJust());
396409
uv_fs_t fs_req;
397410
uv_fs_close(nullptr, &fs_req, check.FromJust(), nullptr);
411+
uv_fs_req_cleanup(&fs_req);
398412

399413
// It's not okay for the called of this method to not be able to tell
400414
// whether an exception is pending or not.

src/node_contextify.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ class ContextifyContext {
139139
EscapableHandleScope scope(env->isolate());
140140
Local<FunctionTemplate> function_template =
141141
FunctionTemplate::New(env->isolate());
142-
function_template->SetHiddenPrototype(true);
143142

144143
function_template->SetClassName(sandbox_obj->GetConstructorName());
145144

src/node_zlib.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,16 @@ class ZCtx : public AsyncWrap {
461461

462462
// just pull the ints out of the args and call the other Init
463463
static void Init(const FunctionCallbackInfo<Value>& args) {
464+
// Refs: https://github.com/nodejs/node/issues/16649
465+
// Refs: https://github.com/nodejs/node/issues/14161
466+
if (args.Length() == 5) {
467+
fprintf(stderr,
468+
"WARNING: You are likely using a version of node-tar or npm that "
469+
"is incompatible with this version of Node.js.\nPlease use "
470+
"either the version of npm that is bundled with Node.js, or "
471+
"a version of npm (> 5.5.1 or < 5.4.0) or node-tar (> 4.0.1) "
472+
"that is compatible with Node.js 9 and above.\n");
473+
}
464474
CHECK(args.Length() == 7 &&
465475
"init(windowBits, level, memLevel, strategy, writeResult, writeCallback,"
466476
" dictionary)");

0 commit comments

Comments
 (0)