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

Commit

Permalink
Merge nodejs/node into xplat
Browse files Browse the repository at this point in the history
Merge 11918c4 as of 2017-05-16

PR-URL: #245
Reviewed-By: Kyle Farnung <Kyle.Farnung@microsoft.com>
  • Loading branch information
kunalspathak authored and New Name committed May 18, 2017
2 parents bfbf736 + 11918c4 commit 297b176
Show file tree
Hide file tree
Showing 33 changed files with 178 additions and 44 deletions.
7 changes: 7 additions & 0 deletions COLLABORATOR_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ not can often be based on many complex factors that are not easily codified. It
is also possible that the breaking commit can be labeled retroactively as a
semver-major change that will not be backported to Current or LTS branches.

##### Reverting commits

Commits are reverted with `git revert <HASH>`, or `git revert <FROM>..<TO>` for
multiple commits. Commit metadata and the reason for the revert should be
appended. Commit message rules about line length and subsystem can be ignored.
A Pull Request should be raised and approved like any other change.

### Deprecations

Deprecation refers to the identification of Public APIs that should no longer
Expand Down
2 changes: 1 addition & 1 deletion benchmark/misc/function_call/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ extern "C" void init (Local<Object> target) {
NODE_SET_METHOD(target, "hello", Hello);
}

NODE_MODULE(binding, init);
NODE_MODULE(binding, init)
2 changes: 1 addition & 1 deletion deps/v8/include/v8-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#define V8_MAJOR_VERSION 5
#define V8_MINOR_VERSION 8
#define V8_BUILD_NUMBER 283
#define V8_PATCH_LEVEL 38
#define V8_PATCH_LEVEL 39

// Use 1 for candidates and 0 otherwise.
// (Boolean macro values are not supported by all preprocessors.)
Expand Down
5 changes: 5 additions & 0 deletions deps/v8/include/v8.h
Original file line number Diff line number Diff line change
Expand Up @@ -7982,6 +7982,11 @@ class V8_EXPORT TryCatch {
*/
void SetVerbose(bool value);

/**
* Returns true if verbosity is enabled.
*/
bool IsVerbose() const;

/**
* Set whether or not this TryCatch should capture a Message object
* which holds source information about where the exception
Expand Down
4 changes: 4 additions & 0 deletions deps/v8/src/api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2691,6 +2691,10 @@ void v8::TryCatch::SetVerbose(bool value) {
is_verbose_ = value;
}

bool v8::TryCatch::IsVerbose() const {
return is_verbose_;
}


void v8::TryCatch::SetCaptureMessage(bool value) {
capture_message_ = value;
Expand Down
2 changes: 1 addition & 1 deletion doc/api/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ void init(Local<Object> exports) {
AtExit(at_exit_cb1, exports->GetIsolate());
}

NODE_MODULE(addon, init);
NODE_MODULE(addon, init)

} // namespace demo
```
Expand Down
7 changes: 4 additions & 3 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2931,11 +2931,12 @@ NAPI_EXTERN napi_status napi_cancel_async_work(napi_env env,

Returns `napi_ok` if the API succeeded.

This API cancels a previously allocated work, provided
it has not yet been queued for execution. After this function is called
This API cancels queued work if it has not yet
been started. If it has already started executing, it cannot be
cancelled and `napi_generic_failure` will be returned. If successful,
the `complete` callback will be invoked with a status value of
`napi_cancelled`. The work should not be deleted before the `complete`
callback invocation, even when it was cancelled.
callback invocation, even if it has been successfully cancelled.


[Aynchronous Operations]: #n_api_asynchronous_operations
Expand Down
5 changes: 5 additions & 0 deletions doc/api/tls.md
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,9 @@ decrease overall server throughput.
<!-- YAML
added: v0.11.3
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/12839
description: The `lookup` option is supported now.
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/11984
description: The `ALPNProtocols` and `NPNProtocols` options can
Expand Down Expand Up @@ -809,6 +812,7 @@ changes:
`tls.createSecureContext()`. *Note*: In effect, all
[`tls.createSecureContext()`][] options can be provided, but they will be
_completely ignored_ unless the `secureContext` option is missing.
* `lookup`: {Function} Custom lookup function. Defaults to [`dns.lookup()`][].
* ...: Optional [`tls.createSecureContext()`][] options can be provided, see
the `secureContext` option for more information.
* `callback` {Function}
Expand Down Expand Up @@ -1291,3 +1295,4 @@ where `secure_socket` has the same API as `pair.cleartext`.
[modifying the default cipher suite]: #tls_modifying_the_default_tls_cipher_suite
[specific attacks affecting larger AES key sizes]: https://www.schneier.com/blog/archives/2009/07/another_new_aes.html
[tls.Server]: #tls_class_tls_server
[`dns.lookup()`]: dns.html#dns_dns_lookup_hostname_options_callback
2 changes: 1 addition & 1 deletion lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ function ReadableState(options, stream) {
this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;

// cast to ints.
this.highWaterMark = ~~this.highWaterMark;
this.highWaterMark = Math.floor(this.highWaterMark);

// A linked list is used to store data chunks instead of an array because the
// linked list can remove elements from the beginning faster than
Expand Down
2 changes: 1 addition & 1 deletion lib/_stream_writable.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function WritableState(options, stream) {
this.highWaterMark = (hwm || hwm === 0) ? hwm : defaultHwm;

// cast to ints.
this.highWaterMark = ~~this.highWaterMark;
this.highWaterMark = Math.floor(this.highWaterMark);

// drain event flag.
this.needDrain = false;
Expand Down
12 changes: 5 additions & 7 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const util = require('util');
const common = require('_tls_common');
const StreamWrap = require('_stream_wrap').StreamWrap;
const Buffer = require('buffer').Buffer;
const Duplex = require('stream').Duplex;
const debug = util.debuglog('tls');
const Timer = process.binding('timer_wrap').Timer;
const tls_wrap = process.binding('tls_wrap');
Expand Down Expand Up @@ -275,12 +274,10 @@ function TLSSocket(socket, options) {

// Wrap plain JS Stream into StreamWrap
var wrap;
if (!(socket instanceof net.Socket) && socket instanceof Duplex)
wrap = new StreamWrap(socket);
else if ((socket instanceof net.Socket) && !socket._handle)
wrap = new StreamWrap(socket);
else
if ((socket instanceof net.Socket && socket._handle) || !socket)
wrap = socket;
else
wrap = new StreamWrap(socket);

// Just a documented property to make secure sockets
// distinguishable from regular ones.
Expand Down Expand Up @@ -1066,7 +1063,8 @@ exports.connect = function(...args /* [port,] [host,] [options,] [cb] */) {
port: options.port,
host: options.host,
family: options.family,
localAddress: options.localAddress
localAddress: options.localAddress,
lookup: options.lookup
};
}
socket.connect(connect_opt, function() {
Expand Down
8 changes: 4 additions & 4 deletions src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2681,9 +2681,9 @@ void FatalException(Isolate* isolate,

void FatalException(Isolate* isolate, const TryCatch& try_catch) {
HandleScope scope(isolate);
// TODO(bajtos) do not call FatalException if try_catch is verbose
// (requires V8 API to expose getter for try_catch.is_verbose_)
FatalException(isolate, try_catch.Exception(), try_catch.Message());
if (!try_catch.IsVerbose()) {
FatalException(isolate, try_catch.Exception(), try_catch.Message());
}
}


Expand Down Expand Up @@ -5001,5 +5001,5 @@ int Start(int argc, char** argv) {
#if !HAVE_INSPECTOR
static void InitEmptyBindings() {}

NODE_MODULE_CONTEXT_AWARE_BUILTIN(inspector, InitEmptyBindings);
NODE_MODULE_CONTEXT_AWARE_BUILTIN(inspector, InitEmptyBindings)
#endif // !HAVE_INSPECTOR
2 changes: 1 addition & 1 deletion src/node_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2781,7 +2781,7 @@ class Work {
// report it as a fatal exception. (There is no JavaScript on the
// callstack that can possibly handle it.)
if (!env->last_exception.IsEmpty()) {
v8::TryCatch try_catch;
v8::TryCatch try_catch(env->isolate);
env->isolate->ThrowException(
v8::Local<v8::Value>::New(env->isolate, env->last_exception));
node::FatalException(env->isolate, try_catch);
Expand Down
2 changes: 1 addition & 1 deletion src/node_contextify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1059,4 +1059,4 @@ void InitContextify(Local<Object> target,
} // anonymous namespace
} // namespace node

NODE_MODULE_CONTEXT_AWARE_BUILTIN(contextify, node::InitContextify);
NODE_MODULE_CONTEXT_AWARE_BUILTIN(contextify, node::InitContextify)
8 changes: 8 additions & 0 deletions test/addons-napi/test_globals/binding.gyp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"targets": [
{
"target_name": "test_globals",
"sources": [ "test_globals.c" ]
}
]
}
8 changes: 8 additions & 0 deletions test/addons-napi/test_globals/test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';
const common = require('../../common');
const assert = require('assert');

const test_globals = require(`./build/${common.buildType}/test_globals`);

assert.strictEqual(test_globals.getUndefined(), undefined);
assert.strictEqual(test_globals.getNull(), null);
26 changes: 26 additions & 0 deletions test/addons-napi/test_globals/test_globals.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <node_api.h>
#include "../common.h"

napi_value getNull(napi_env env, napi_callback_info info) {
napi_value result;
NAPI_CALL(env, napi_get_null(env, &result));
return result;
}

napi_value getUndefined(napi_env env, napi_callback_info info) {
napi_value result;
NAPI_CALL(env, napi_get_undefined(env, &result));
return result;
}

void Init(napi_env env, napi_value exports, napi_value module, void* priv) {
napi_property_descriptor descriptors[] = {
DECLARE_NAPI_PROPERTY("getUndefined", getUndefined),
DECLARE_NAPI_PROPERTY("getNull", getNull),
};

NAPI_CALL_RETURN_VOID(env, napi_define_properties(
env, exports, sizeof(descriptors) / sizeof(*descriptors), descriptors));
}

NAPI_MODULE(addon, Init)
2 changes: 1 addition & 1 deletion test/addons/async-hello-world/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ void init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) {
NODE_SET_METHOD(module, "exports", Method);
}

NODE_MODULE(binding, init);
NODE_MODULE(binding, init)
2 changes: 1 addition & 1 deletion test/addons/at-exit/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ void init(Local<Object> exports) {
atexit(sanity_check);
}

NODE_MODULE(binding, init);
NODE_MODULE(binding, init)
2 changes: 1 addition & 1 deletion test/addons/buffer-free-callback/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ void init(v8::Local<v8::Object> exports) {
NODE_SET_METHOD(exports, "check", Check);
}

NODE_MODULE(binding, init);
NODE_MODULE(binding, init)
2 changes: 1 addition & 1 deletion test/addons/hello-world-function-export/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ void init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) {
NODE_SET_METHOD(module, "exports", Method);
}

NODE_MODULE(binding, init);
NODE_MODULE(binding, init)
2 changes: 1 addition & 1 deletion test/addons/hello-world/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ void init(v8::Local<v8::Object> exports) {
NODE_SET_METHOD(exports, "hello", Method);
}

NODE_MODULE(binding, init);
NODE_MODULE(binding, init)
2 changes: 1 addition & 1 deletion test/addons/load-long-path/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ void init(v8::Local<v8::Object> exports) {
NODE_SET_METHOD(exports, "hello", Method);
}

NODE_MODULE(binding, init);
NODE_MODULE(binding, init)
2 changes: 1 addition & 1 deletion test/addons/null-buffer-neuter/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ void init(v8::Local<v8::Object> exports) {
NODE_SET_METHOD(exports, "run", Run);
}

NODE_MODULE(binding, init);
NODE_MODULE(binding, init)
2 changes: 1 addition & 1 deletion test/addons/parse-encoding/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ void Initialize(v8::Local<v8::Object> exports) {

} // anonymous namespace

NODE_MODULE(binding, Initialize);
NODE_MODULE(binding, Initialize)
2 changes: 1 addition & 1 deletion test/addons/repl-domain-abort/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ void init(Local<Object> exports) {
NODE_SET_METHOD(exports, "method", Method);
}

NODE_MODULE(binding, init);
NODE_MODULE(binding, init)
2 changes: 1 addition & 1 deletion test/addons/stringbytes-external-exceed-max/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ void init(v8::Local<v8::Object> exports) {
NODE_SET_METHOD(exports, "ensureAllocation", EnsureAllocation);
}

NODE_MODULE(binding, init);
NODE_MODULE(binding, init)
2 changes: 1 addition & 1 deletion test/addons/symlinked-module/binding.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ void init(v8::Local<v8::Object> exports) {
NODE_SET_METHOD(exports, "hello", Method);
}

NODE_MODULE(binding, init);
NODE_MODULE(binding, init)
18 changes: 18 additions & 0 deletions test/parallel/test-streams-highwatermark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';
require('../common');

// This test ensures that the stream implementation correctly handles values
// for highWaterMark which exceed the range of signed 32 bit integers.

const assert = require('assert');
const stream = require('stream');

// This number exceeds the range of 32 bit integer arithmetic but should still
// be handled correctly.
const ovfl = Number.MAX_SAFE_INTEGER;

const readable = stream.Readable({ highWaterMark: ovfl });
assert.strictEqual(readable._readableState.highWaterMark, ovfl);

const writable = stream.Writable({ highWaterMark: ovfl });
assert.strictEqual(writable._writableState.highWaterMark, ovfl);
32 changes: 32 additions & 0 deletions test/parallel/test-tls-lookup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict';
const common = require('../common');
const assert = require('assert');
const tls = require('tls');

const expectedError = /^TypeError: "lookup" option should be a function$/;

['foobar', 1, {}, []].forEach(function connectThrows(input) {
const opts = {
host: 'localhost',
port: common.PORT,
lookup: input
};

assert.throws(function() {
tls.connect(opts);
}, expectedError);
});

connectDoesNotThrow(common.mustCall(() => {}));

function connectDoesNotThrow(input) {
const opts = {
host: 'localhost',
port: common.PORT,
lookup: input
};

assert.doesNotThrow(function() {
tls.connect(opts);
});
}
16 changes: 16 additions & 0 deletions test/parallel/test-tls-wrap-event-emmiter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

/*
* Issue: https://github.com/nodejs/node/issues/3655
* Test checks if we get exception instead of runtime error
*/

require('../common');
const assert = require('assert');

const TlsSocket = require('tls').TLSSocket;
const EventEmitter = require('events').EventEmitter;
assert.throws(
() => { new TlsSocket(new EventEmitter()); },
/^TypeError: this\.stream\.pause is not a function/
);
11 changes: 7 additions & 4 deletions test/parallel/test-url-parse-invalid-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ const url = require('url');
0.0,
0,
[],
{}
].forEach(function(val) {
assert.throws(function() { url.parse(val); }, TypeError);
{},
() => {},
Symbol('foo')
].forEach((val) => {
assert.throws(() => { url.parse(val); },
/^TypeError: Parameter "url" must be a string, not (undefined|boolean|number|object|function|symbol)$/);
});

const engineSpecificMalformedUrlError =
Expand All @@ -23,4 +26,4 @@ const engineSpecificMalformedUrlError =
chakracore: /^URIError: The URI to be decoded is not a valid encoding$/
});

assert.throws(function() { url.parse('http://%E0%A4%A@fail'); }, engineSpecificMalformedUrlError);
assert.throws(() => { url.parse('http://%E0%A4%A@fail'); }, engineSpecificMalformedUrlError);
Loading

0 comments on commit 297b176

Please sign in to comment.