grpc / grpc-web

gRPC for Web Clients
https://grpc.io
Apache License 2.0
8.56k stars 762 forks source link

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

Closed sampajano closed 2 years ago

sampajano commented 2 years ago

The issue

This is a temporary hack to fix https://github.com/grpc/grpc-web/issues/1153, which is caused by goog.global not properly pointing to the proper global scope (e.g. window) when grpc-web is being imported as a CommonJS module (because this points to the module scope instead of actual global scope (i.e. globalThis)).

goog.Timer.defaultTimerObject is set to point to goog.global, and that's why it throws when setTimeout is called on it.

The fix