mirror of https://github.com/grpc/grpc-node.git
Merge remote-tracking branch 'upstream/v1.9.x' into v1.9.x_initial_version_bump
This commit is contained in:
commit
a248009cb9
|
@ -38,7 +38,7 @@
|
|||
"through2": "^2.0.3",
|
||||
"ts-node": "^3.3.0",
|
||||
"tslint": "^5.5.0",
|
||||
"typescript": "^2.5.1",
|
||||
"typescript": "~2.7.0",
|
||||
"xml2js": "^0.4.19"
|
||||
},
|
||||
"contributors": [
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
"@types/node": "^8.0.55",
|
||||
"clang-format": "^1.0.55",
|
||||
"gts": "^0.5.1",
|
||||
"typescript": "^2.6.1"
|
||||
"typescript": "~2.7.0"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
|
|
|
@ -76,7 +76,7 @@ export class Http2Channel extends EventEmitter implements Channel {
|
|||
private connectivityState: ConnectivityState = ConnectivityState.IDLE;
|
||||
/* For now, we have up to one subchannel, which will exist as long as we are
|
||||
* connecting or trying to connect */
|
||||
private subChannel: http2.ClientHttp2Session|null;
|
||||
private subChannel: http2.ClientHttp2Session|null = null;
|
||||
private filterStackFactory: FilterStackFactory;
|
||||
|
||||
private subChannelConnectCallback: ()=>void = () => {};
|
||||
|
@ -123,7 +123,7 @@ export class Http2Channel extends EventEmitter implements Channel {
|
|||
}
|
||||
|
||||
// Transition from any of a set of oldStates to a specific newState
|
||||
private transitionToState(oldStates: [ConnectivityState], newState: ConnectivityState): void {
|
||||
private transitionToState(oldStates: ConnectivityState[], newState: ConnectivityState): void {
|
||||
if (oldStates.indexOf(this.connectivityState) > -1) {
|
||||
let oldState: ConnectivityState = this.connectivityState;
|
||||
this.connectivityState = newState;
|
||||
|
|
|
@ -38,11 +38,11 @@ class ClientHttp2StreamMock extends stream.Duplex implements http2.ClientHttp2St
|
|||
}
|
||||
bytesRead = 0;
|
||||
dataFrame = 0;
|
||||
aborted: boolean;
|
||||
destroyed: boolean;
|
||||
rstCode: number;
|
||||
session: http2.Http2Session;
|
||||
state: http2.StreamState;
|
||||
aborted: boolean = false;
|
||||
destroyed: boolean = false;
|
||||
rstCode: number = 0;
|
||||
session: http2.Http2Session = {} as any;
|
||||
state: http2.StreamState = {} as any;
|
||||
priority = mockFunction;
|
||||
rstStream = mockFunction;
|
||||
rstWithNoError = mockFunction;
|
||||
|
|
|
@ -8,7 +8,7 @@ import {ChannelCredentials} from '../src/channel-credentials';
|
|||
import {assert2, mockFunction} from './common';
|
||||
|
||||
class CallCredentialsMock implements CallCredentials {
|
||||
child: CallCredentialsMock;
|
||||
child: CallCredentialsMock|null = null;
|
||||
constructor(child?: CallCredentialsMock) {
|
||||
if (child) {
|
||||
this.child = child;
|
||||
|
|
|
@ -29,6 +29,6 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"gts": "^0.5.1",
|
||||
"typescript": "^2.6.1"
|
||||
"typescript": "~2.7.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,22 @@ var Duplex = stream.Duplex;
|
|||
var util = require('util');
|
||||
var version = require('../package.json').version;
|
||||
|
||||
/**
|
||||
* Create an Error object from a status object
|
||||
* @private
|
||||
* @param {grpc~StatusObject} status The status object
|
||||
* @return {Error} The resulting Error
|
||||
*/
|
||||
function createStatusError(status) {
|
||||
let statusName = _.invert(constants.status)[status.code];
|
||||
let message = `${status.code} ${statusName}: ${status.details}`;
|
||||
let error = new Error(message);
|
||||
error.code = status.code;
|
||||
error.metadata = status.metadata;
|
||||
error.details = status.details;
|
||||
return error;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initial response metadata sent by the server when it starts processing the
|
||||
* call
|
||||
|
@ -251,9 +267,7 @@ function _emitStatusIfDone() {
|
|||
if (status.code === constants.status.OK) {
|
||||
this.push(null);
|
||||
} else {
|
||||
var error = new Error(status.details);
|
||||
error.code = status.code;
|
||||
error.metadata = status.metadata;
|
||||
var error = createStatusError(status);
|
||||
this.emit('error', error);
|
||||
}
|
||||
this.emit('status', status);
|
||||
|
@ -556,9 +570,7 @@ Client.prototype.makeUnaryRequest = function(method, serialize, deserialize,
|
|||
}
|
||||
}
|
||||
if (status.code !== constants.status.OK) {
|
||||
error = new Error(status.details);
|
||||
error.code = status.code;
|
||||
error.metadata = status.metadata;
|
||||
error = new createStatusError(status);
|
||||
callback(error);
|
||||
} else {
|
||||
callback(null, deserialized);
|
||||
|
@ -645,9 +657,7 @@ Client.prototype.makeClientStreamRequest = function(method, serialize,
|
|||
}
|
||||
}
|
||||
if (status.code !== constants.status.OK) {
|
||||
error = new Error(response.status.details);
|
||||
error.code = status.code;
|
||||
error.metadata = status.metadata;
|
||||
error = createStatusError(status);
|
||||
callback(error);
|
||||
} else {
|
||||
callback(null, deserialized);
|
||||
|
|
|
@ -319,7 +319,7 @@ describe('client credentials', function() {
|
|||
client_options);
|
||||
client.unary({}, function(err, data) {
|
||||
assert(err);
|
||||
assert.strictEqual(err.message,
|
||||
assert.strictEqual(err.details,
|
||||
'Getting metadata from plugin failed with error: ' +
|
||||
'Authentication error');
|
||||
assert.notStrictEqual(err.code, grpc.status.OK);
|
||||
|
@ -369,7 +369,7 @@ describe('client credentials', function() {
|
|||
client_options);
|
||||
client.unary({}, function(err, data) {
|
||||
assert(err);
|
||||
assert.strictEqual(err.message,
|
||||
assert.strictEqual(err.details,
|
||||
'Getting metadata from plugin failed with error: ' +
|
||||
'Authentication failure');
|
||||
done();
|
||||
|
|
|
@ -981,7 +981,7 @@ describe('Other conditions', function() {
|
|||
client.unary({error: true}, function(err, data) {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, grpc.status.UNKNOWN);
|
||||
assert.strictEqual(err.message, 'Requested error');
|
||||
assert.strictEqual(err.details, 'Requested error');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -989,7 +989,7 @@ describe('Other conditions', function() {
|
|||
var call = client.clientStream(function(err, data) {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, grpc.status.UNKNOWN);
|
||||
assert.strictEqual(err.message, 'Requested error');
|
||||
assert.strictEqual(err.details, 'Requested error');
|
||||
done();
|
||||
});
|
||||
call.write({error: false});
|
||||
|
@ -1001,7 +1001,7 @@ describe('Other conditions', function() {
|
|||
call.on('data', function(){});
|
||||
call.on('error', function(error) {
|
||||
assert.strictEqual(error.code, grpc.status.UNKNOWN);
|
||||
assert.strictEqual(error.message, 'Requested error');
|
||||
assert.strictEqual(error.details, 'Requested error');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -1013,7 +1013,7 @@ describe('Other conditions', function() {
|
|||
call.on('data', function(){});
|
||||
call.on('error', function(error) {
|
||||
assert.strictEqual(error.code, grpc.status.UNKNOWN);
|
||||
assert.strictEqual(error.message, 'Requested error');
|
||||
assert.strictEqual(error.details, 'Requested error');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -347,7 +347,7 @@ function statusCodeAndMessage(client, done) {
|
|||
client.unaryCall(arg, function(err, resp) {
|
||||
assert(err);
|
||||
assert.strictEqual(err.code, 2);
|
||||
assert.strictEqual(err.message, 'test status message');
|
||||
assert.strictEqual(err.details, 'test status message');
|
||||
done();
|
||||
});
|
||||
var duplex = client.fullDuplexCall();
|
||||
|
|
Loading…
Reference in New Issue