Skip to content

Commit

Permalink
Grpc test server always waits serverWait before responding (#360)
Browse files Browse the repository at this point in the history
PR-URL: #360
  • Loading branch information
matthewloring authored Feb 1, 2017
1 parent ba0182c commit 9c8e610
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions test/hooks/test-trace-grpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,12 @@ Object.keys(versions).forEach(function(version) {
});
call.on('end', function() {
if (sum === EMIT_ERROR) {
if (stopChildSpan) {
stopChildSpan();
}
cb(new Error('test'));
triggerCb = function() {
if (stopChildSpan) {
stopChildSpan();
}
cb(new Error('test'));
};
} else if (sum === SEND_METADATA) {
call.sendMetadata(metadata);
triggerCb = function() {
Expand Down Expand Up @@ -113,7 +115,7 @@ Object.keys(versions).forEach(function(version) {
testBidiStream: function(stream) {
var sum = 0;
var stopChildSpan;
setTimeout(function() {
var t = setTimeout(function() {
stream.end();
}, common.serverWait);
stream.on('data', function(data) {
Expand All @@ -128,10 +130,13 @@ Object.keys(versions).forEach(function(version) {
stream.on('end', function() {
stopChildSpan();
if (sum === EMIT_ERROR) {
if (stopChildSpan) {
stopChildSpan();
}
stream.emit('error', new Error('test'));
clearTimeout(t);
setTimeout(function() {
if (stopChildSpan) {
stopChildSpan();
}
stream.emit('error', new Error('test'));
}, common.serverWait);
} else if (sum === SEND_METADATA) {
stream.sendMetadata(metadata);
}
Expand Down

0 comments on commit 9c8e610

Please sign in to comment.