Skip to content

V1.9.x upmerge #191

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Feb 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
56d5bbd
Bump version to 1.9.0-pre3
murgatroid99 Jan 31, 2018
7fa0bd6
Merge pull request #166 from grpc/master
murgatroid99 Feb 1, 2018
a248009
Merge remote-tracking branch 'upstream/v1.9.x' into v1.9.x_initial_ve…
murgatroid99 Feb 1, 2018
d598ba0
Merge pull request #167 from murgatroid99/v1.9.x_initial_version_bump
murgatroid99 Feb 1, 2018
e87552d
Fix documentation of part of the type signature for server credentials
murgatroid99 Feb 5, 2018
77e4376
Merge pull request #171 from murgatroid99/key_cert_pair_type_fix
murgatroid99 Feb 7, 2018
2f77364
Update version to 1.9.0
murgatroid99 Feb 8, 2018
51c8503
Improve module load error message when the directory does not exist
murgatroid99 Feb 8, 2018
b7f122b
Merge two lines of the error message
murgatroid99 Feb 8, 2018
650b5d5
Merge pull request #175 from murgatroid99/file_error_improvement
murgatroid99 Feb 8, 2018
f4d3139
Merge pull request #174 from murgatroid99/v1.9.0_update
murgatroid99 Feb 8, 2018
2f649e5
Fix usage of Protobuf.js Message type in TS file
murgatroid99 Feb 9, 2018
42a1530
Merge pull request #177 from murgatroid99/ts_message_type_fix
murgatroid99 Feb 9, 2018
ca27049
Fix handling of undefined values for optional call arguments
murgatroid99 Feb 13, 2018
b5facc9
Merge pull request #179 from murgatroid99/call_argument_handling_fix
murgatroid99 Feb 13, 2018
d6c5c4f
Update version to 1.9.1
murgatroid99 Feb 14, 2018
bea8fa6
Merge pull request #182 from murgatroid99/version_1.9.1
murgatroid99 Feb 15, 2018
eb1db93
Merge remote-tracking branch 'upstream/v1.9.x' into v1.9.x_upmerge
murgatroid99 Feb 22, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/grpc-native-core/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ declare module "grpc" {
* - Anything else becomes the relevant reflection object that ProtoBuf.js would create
*/
export interface GrpcObject {
[name: string]: GrpcObject | typeof Client | Message;
[name: string]: GrpcObject | typeof Client | Message<any>;
}

/**
Expand Down Expand Up @@ -573,12 +573,12 @@ declare module "grpc" {
/**
* The server's private key
*/
privateKey: Buffer;
private_key: Buffer;

/**
* The server's certificate chain
*/
certChain: Buffer;
cert_chain: Buffer;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/grpc-native-core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ exports.ServerCredentials = grpc.ServerCredentials;
/**
* A private key and certificate pair
* @typedef {Object} grpc.ServerCredentials~keyCertPair
* @property {Buffer} privateKey The server's private key
* @property {Buffer} certChain The server's certificate chain
* @property {Buffer} private_key The server's private key
* @property {Buffer} cert_chain The server's certificate chain
*/

/**
Expand Down
36 changes: 28 additions & 8 deletions packages/grpc-native-core/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,23 @@ exports.Client = Client;
Client.prototype.makeUnaryRequest = function(method, serialize, deserialize,
argument, metadata, options,
callback) {
if (!(metadata instanceof Metadata)) {
if (options instanceof Function) {
callback = options;
options = metadata;
if (metadata instanceof Metadata) {
options = {};
} else {
options = metadata;
metadata = new Metadata();
}
} else if (metadata instanceof Function) {
callback = metadata;
metadata = new Metadata();
options = {};
}
if (options instanceof Function) {
callback = options;
if (!metadata) {
metadata = new Metadata();
}
if (!options) {
options = {};
}
if (!((metadata instanceof Metadata) &&
Expand Down Expand Up @@ -599,13 +609,23 @@ Client.prototype.makeUnaryRequest = function(method, serialize, deserialize,
Client.prototype.makeClientStreamRequest = function(method, serialize,
deserialize, metadata,
options, callback) {
if (!(metadata instanceof Metadata)) {
if (options instanceof Function) {
callback = options;
options = metadata;
if (metadata instanceof Metadata) {
options = {};
} else {
options = metadata;
metadata = new Metadata();
}
} else if (metadata instanceof Function) {
callback = metadata;
metadata = new Metadata();
options = {};
}
if (options instanceof Function) {
callback = options;
if (!metadata) {
metadata = new Metadata();
}
if (!options) {
options = {};
}
if (!((metadata instanceof Metadata) &&
Expand Down
21 changes: 15 additions & 6 deletions packages/grpc-native-core/src/grpc_extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,26 @@ var binding;
try {
binding = require(binding_path);
} catch (e) {
var fs = require('fs');
var searchPath = path.dirname(path.dirname(binding_path));
var searchName = path.basename(path.dirname(binding_path));
var foundNames = fs.readdirSync(searchPath);
let fs = require('fs');
let searchPath = path.dirname(path.dirname(binding_path));
let searchName = path.basename(path.dirname(binding_path));
let foundNames;
try {
foundNames = fs.readdirSync(searchPath);
} catch (readDirError) {
let message = `The gRPC binary module was not installed. This may be fixed by running "npm rebuild"
Original error: ${e.message}`;
let error = new Error(message);
error.code = e.code;
throw error;
}
if (foundNames.indexOf(searchName) === -1) {
var message = `Failed to load gRPC binary module because it was not installed for the current system
let message = `Failed to load gRPC binary module because it was not installed for the current system
Expected directory: ${searchName}
Found: [${foundNames.join(', ')}]
This problem can often be fixed by running "npm rebuild" on the current system
Original error: ${e.message}`;
var error = new Error(message);
let error = new Error(message);
error.code = e.code;
throw error;
} else {
Expand Down
110 changes: 110 additions & 0 deletions test/api/surface_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,116 @@ describe('Echo metadata', function() {
done();
});
});
describe('Call argument handling', function() {
describe('Unary call', function() {
it('Should handle undefined options', function(done) {
var call = client.unary({}, metadata, undefined, function(err, data) {
assert.ifError(err);
});
call.on('metadata', function(metadata) {
assert.deepEqual(metadata.get('key'), ['value']);
done();
});
});
it('Should handle two undefined arguments', function(done) {
var call = client.unary({}, undefined, undefined, function(err, data) {
assert.ifError(err);
});
call.on('metadata', function(metadata) {
done();
});
});
it('Should handle one undefined argument', function(done) {
var call = client.unary({}, undefined, function(err, data) {
assert.ifError(err);
});
call.on('metadata', function(metadata) {
done();
});
});
});
describe('Client stream call', function() {
it('Should handle undefined options', function(done) {
var call = client.clientStream(metadata, undefined, function(err, data) {
assert.ifError(err);
});
call.on('metadata', function(metadata) {
assert.deepEqual(metadata.get('key'), ['value']);
done();
});
call.end();
});
it('Should handle two undefined arguments', function(done) {
var call = client.clientStream(undefined, undefined, function(err, data) {
assert.ifError(err);
});
call.on('metadata', function(metadata) {
done();
});
call.end();
});
it('Should handle one undefined argument', function(done) {
var call = client.clientStream(undefined, function(err, data) {
assert.ifError(err);
});
call.on('metadata', function(metadata) {
done();
});
call.end();
});
});
describe('Server stream call', function() {
it('Should handle undefined options', function(done) {
var call = client.serverStream({}, metadata, undefined);
call.on('data', function() {});
call.on('metadata', function(metadata) {
assert.deepEqual(metadata.get('key'), ['value']);
done();
});
});
it('Should handle two undefined arguments', function(done) {
var call = client.serverStream({}, undefined, undefined);
call.on('data', function() {});
call.on('metadata', function(metadata) {
done();
});
});
it('Should handle one undefined argument', function(done) {
var call = client.serverStream({}, undefined);
call.on('data', function() {});
call.on('metadata', function(metadata) {
done();
});
});
});
describe('Bidi stream call', function() {
it('Should handle undefined options', function(done) {
var call = client.bidiStream(metadata, undefined);
call.on('data', function() {});
call.on('metadata', function(metadata) {
assert.deepEqual(metadata.get('key'), ['value']);
done();
});
call.end();
});
it('Should handle two undefined arguments', function(done) {
var call = client.bidiStream(undefined, undefined);
call.on('data', function() {});
call.on('metadata', function(metadata) {
done();
});
call.end();
});
it('Should handle one undefined argument', function(done) {
var call = client.bidiStream(undefined);
call.on('data', function() {});
call.on('metadata', function(metadata) {
done();
});
call.end();
});
});
});
});
describe('Client malformed response handling', function() {
var server;
Expand Down