Skip to content
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

grpc: listen for metadata event instead of status #1444

Merged
merged 4 commits into from
Jul 22, 2016
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
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 lib/common/grpc-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,10 +325,10 @@ GrpcService.prototype.requestStream = function(protoOpts, reqOpts) {

request: function() {
return service[protoOpts.method](reqOpts, grpcOpts)
.on('status', function(status) {
var grcpStatus = GrpcService.decorateStatus_(status);
.on('metadata', function() {
var grcpStatus = GrpcService.decorateStatus_({ code: 0 });

This comment was marked as spam.

This comment was marked as spam.


this.emit('response', grcpStatus || status);
this.emit('response', grcpStatus);
});
}
};
Expand Down
8 changes: 4 additions & 4 deletions test/common/grpc-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -1062,8 +1062,7 @@ describe('GrpcService', function() {
);
});

it('should emit the status as a response event', function(done) {
var grpcError500 = { code: 2 };
it('should emit the metadata event as a response event', function(done) {
var fakeStream = through.obj();

ProtoService.prototype.method = function() {
Expand All @@ -1075,13 +1074,14 @@ describe('GrpcService', function() {
};

fakeStream
.on('error', done)
.on('response', function(resp) {

This comment was marked as spam.

assert.deepEqual(resp, GrpcService.GRPC_ERROR_CODE_TO_HTTP[2]);
assert.deepEqual(resp, GrpcService.GRPC_ERROR_CODE_TO_HTTP[0]);
done();
});

grpcService.requestStream(PROTO_OPTS, REQ_OPTS);
fakeStream.emit('status', grpcError500);
fakeStream.emit('metadata');
});

it('should emit the response error', function(done) {
Expand Down