From d471ac7e2c6a2313b0685203dc4ae923ab2a776a Mon Sep 17 00:00:00 2001 From: Yoshi Automation Bot Date: Fri, 12 Jun 2020 10:45:11 -0700 Subject: [PATCH] fix: handle fallback option properly (#402) * changes without context autosynth cannot find the source of changes triggered by earlier changes in this repository, or by version upgrades to tools such as linters. * chore(nodejs_templates): add script logging to node_library populate-secrets.sh Co-authored-by: Benjamin E. Coe Source-Author: BenWhitehead Source-Date: Wed Jun 10 22:24:28 2020 -0400 Source-Repo: googleapis/synthtool Source-Sha: e7034945fbdc0e79d3c57f6e299e5c90b0f11469 Source-Link: https://github.com/googleapis/synthtool/commit/e7034945fbdc0e79d3c57f6e299e5c90b0f11469 --- .../google-cloud-redis/src/v1/cloud_redis_client.ts | 13 +++++-------- .../src/v1beta1/cloud_redis_client.ts | 13 +++++-------- packages/google-cloud-redis/synth.metadata | 4 ++-- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/packages/google-cloud-redis/src/v1/cloud_redis_client.ts b/packages/google-cloud-redis/src/v1/cloud_redis_client.ts index 27213a05044..fe7a0b74b77 100644 --- a/packages/google-cloud-redis/src/v1/cloud_redis_client.ts +++ b/packages/google-cloud-redis/src/v1/cloud_redis_client.ts @@ -124,14 +124,11 @@ export class CloudRedisClient { // const showcaseClient = new showcaseClient({ projectId, customConfig }); opts.clientConfig = opts.clientConfig || {}; - const isBrowser = typeof window !== 'undefined'; - if (isBrowser) { - opts.fallback = true; - } - // If we are in browser, we are already using fallback because of the - // "browser" field in package.json. - // But if we were explicitly requested to use fallback, let's do it now. - this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + // If we're running in browser, it's OK to omit `fallback` since + // google-gax has `browser` field in its `package.json`. + // For Electron (which does not respect `browser` field), + // pass `{fallback: true}` to the CloudRedisClient constructor. + this._gaxModule = opts.fallback ? gax.fallback : gax; // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. diff --git a/packages/google-cloud-redis/src/v1beta1/cloud_redis_client.ts b/packages/google-cloud-redis/src/v1beta1/cloud_redis_client.ts index de66f59902b..3599d533dc3 100644 --- a/packages/google-cloud-redis/src/v1beta1/cloud_redis_client.ts +++ b/packages/google-cloud-redis/src/v1beta1/cloud_redis_client.ts @@ -124,14 +124,11 @@ export class CloudRedisClient { // const showcaseClient = new showcaseClient({ projectId, customConfig }); opts.clientConfig = opts.clientConfig || {}; - const isBrowser = typeof window !== 'undefined'; - if (isBrowser) { - opts.fallback = true; - } - // If we are in browser, we are already using fallback because of the - // "browser" field in package.json. - // But if we were explicitly requested to use fallback, let's do it now. - this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax; + // If we're running in browser, it's OK to omit `fallback` since + // google-gax has `browser` field in its `package.json`. + // For Electron (which does not respect `browser` field), + // pass `{fallback: true}` to the CloudRedisClient constructor. + this._gaxModule = opts.fallback ? gax.fallback : gax; // Create a `gaxGrpc` object, with any grpc-specific options // sent to the client. diff --git a/packages/google-cloud-redis/synth.metadata b/packages/google-cloud-redis/synth.metadata index 79794e24ad5..4b586a4f07a 100644 --- a/packages/google-cloud-redis/synth.metadata +++ b/packages/google-cloud-redis/synth.metadata @@ -4,7 +4,7 @@ "git": { "name": ".", "remote": "https://github.com/googleapis/nodejs-redis.git", - "sha": "4855114e325b8f2650ac5eff13778c5220aae42e" + "sha": "55a1e1375a27aa016fcdbe8b7b32ada072f4927a" } }, { @@ -19,7 +19,7 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "1c92077459db3dc50741e878f98b08c6261181e0" + "sha": "e7034945fbdc0e79d3c57f6e299e5c90b0f11469" } } ],