Fix issue where no RPC is issued when `deadline` is specified. (#1172)

This commit is contained in:
Eryu Xia 2021-11-19 01:01:18 -08:00 committed by GitHub
parent b849db4dfa
commit cc1a135855
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -19,3 +19,9 @@ module['exports']['GrpcWebClientBase'] = GrpcWebClientBase;
module['exports']['RpcError'] = RpcError;
module['exports']['StatusCode'] = StatusCode;
module['exports']['MethodType'] = MethodType;
// Temporary hack to fix https://github.com/grpc/grpc-web/issues/1153, which is
// caused by `goog.global` not pointing to the global scope when grpc-web is
// being imported as a CommonJS module.
// TODO: Remove this hack after `goog.global` is fixed.
goog.Timer.defaultTimerObject = (typeof globalThis !== "undefined" && globalThis) || self;

View File

@ -50,6 +50,17 @@ function doEmptyUnary(done) {
});
}
function doEmptyUnaryWithDeadline(done) {
var testService = new TestServiceClient(SERVER_HOST, null, null);
const deadlineMs = 1000; // 1 second
testService.emptyCall(new Empty(), {deadline: Date.now() + deadlineMs},
(err, response) => {
assert.ifError(err);
assert(response instanceof Empty);
done();
});
}
function doLargeUnary(done) {
var testService = new TestServiceClient(SERVER_HOST, null, null);
var req = new SimpleRequest();
@ -167,6 +178,7 @@ function doUnimplementedMethod(done) {
var testCases = {
'empty_unary': {testFunc: doEmptyUnary},
'empty_unary_with_deadline': {testFunc: doEmptyUnaryWithDeadline},
'large_unary': {testFunc: doLargeUnary},
'server_streaming': {testFunc: doServerStreaming,
skipBinaryMode: true},