This commit is contained in:
Nicolas "Pixel" Noble 2018-10-25 00:25:12 +02:00
commit 8f09c2b0d0
6 changed files with 42 additions and 10 deletions

View File

@ -1,2 +1,3 @@
settings:
'#': It's possible to have node_version here as a key to override the core's version.
node_version: 1.16.0-pre1

@ -1 +1 @@
Subproject commit bc9e9ddf9e04b1a905d51c41b1ffef5b30f2c986
Subproject commit 98457b76ff43efa2c3edd203c14cd923734d5279

View File

@ -52,7 +52,7 @@ function handleError(call, error) {
if (error.hasOwnProperty('message')) {
status.details = error.message;
}
if (error.hasOwnProperty('code')) {
if (error.hasOwnProperty('code') && Number.isInteger(error.code)) {
status.code = error.code;
if (error.hasOwnProperty('details')) {
status.details = error.details;
@ -954,6 +954,7 @@ Server.prototype.addProtoService = util.deprecate(function(service,
* "address:port"
* @param {grpc.ServerCredentials} creds Server credential object to be used for
* SSL. Pass an insecure credentials object for an insecure port.
* @return {number} The bound port number. Negative if binding the port failed.
*/
Server.prototype.bind = function(port, creds) {
if (this.started) {
@ -962,4 +963,32 @@ Server.prototype.bind = function(port, creds) {
return this._server.addHttp2Port(port, creds);
};
/**
* Called with the result of attempting to bind a port
* @callback grpc.Server~bindCallback
* @param {Error=} error If non-null, indicates that binding the port failed.
* @param {number} port The bound port number. If binding the port fails, this
* will be negative to match the output of bind.
*/
/**
* Binds the server to the given port, with SSL disabled if creds is an
* insecure credentials object. Provides the result asynchronously.
* @param {string} port The port that the server should bind on, in the format
* "address:port"
* @param {grpc.ServerCredentials} creds Server credential object to be used for
* SSL. Pass an insecure credentials object for an insecure port.
*/
Server.prototype.bindAsync = function(port, creds, callback) {
/* This can throw. We do not try to catch that error because it indicates an
* incorrect use of the function, which should not be surfaced asynchronously
*/
const result = this.bind(port, creds)
if (result < 0) {
setImmediate(callback, new Error('Failed to bind port'), result);
} else {
setImmediate(callback, null, result);
}
}
exports.Server = Server;

View File

@ -37,14 +37,16 @@ var getServer = require('./math/math_server.js');
var server = getServer();
let serverCreds = grpc.ServerCredentials.createInsecure();
describe('Async functionality', function() {
before(function(done) {
var port_num = server.bind('0.0.0.0:0',
grpc.ServerCredentials.createInsecure());
server.start();
math_client = new math.Math('localhost:' + port_num,
grpc.credentials.createInsecure());
done();
server.bindAsync('0.0.0.0:0', serverCreds, (error, port_num) => {
server.start();
math_client = new math.Math('localhost:' + port_num,
grpc.credentials.createInsecure());
done();
});
});
after(function() {
grpc.closeClient(math_client);

View File

@ -16,7 +16,7 @@ set arch_list=ia32 x64
set node_versions=4.0.0 5.0.0 6.0.0 7.0.0 8.0.0 9.0.0 10.0.0
set electron_versions=1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 2.0.0
set electron_versions=1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 2.0.0 3.0.0
set PATH=%PATH%;C:\Program Files\nodejs\;%APPDATA%\npm

View File

@ -17,7 +17,7 @@ set -ex
arch_list=( ia32 x64 )
node_versions=( 4.0.0 5.0.0 6.0.0 7.0.0 8.0.0 9.0.0 10.0.0 )
electron_versions=( 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 2.0.0 )
electron_versions=( 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 2.0.0 3.0.0 )
while true ; do
case $1 in