Skip to content

Commit ad59d18

Browse files
fix: handle fallback option properly (#447)
* 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 <bencoe@google.com> Source-Author: BenWhitehead <BenWhitehead@users.noreply.github.com> Source-Date: Wed Jun 10 22:24:28 2020 -0400 Source-Repo: googleapis/synthtool Source-Sha: e7034945fbdc0e79d3c57f6e299e5c90b0f11469 Source-Link: googleapis/synthtool@e703494
1 parent 92ae74e commit ad59d18

7 files changed

Lines changed: 32 additions & 50 deletions

packages/google-cloud-videointelligence/src/v1/video_intelligence_service_client.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,11 @@ export class VideoIntelligenceServiceClient {
106106
// const showcaseClient = new showcaseClient({ projectId, customConfig });
107107
opts.clientConfig = opts.clientConfig || {};
108108

109-
const isBrowser = typeof window !== 'undefined';
110-
if (isBrowser) {
111-
opts.fallback = true;
112-
}
113-
// If we are in browser, we are already using fallback because of the
114-
// "browser" field in package.json.
115-
// But if we were explicitly requested to use fallback, let's do it now.
116-
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
109+
// If we're running in browser, it's OK to omit `fallback` since
110+
// google-gax has `browser` field in its `package.json`.
111+
// For Electron (which does not respect `browser` field),
112+
// pass `{fallback: true}` to the VideoIntelligenceServiceClient constructor.
113+
this._gaxModule = opts.fallback ? gax.fallback : gax;
117114

118115
// Create a `gaxGrpc` object, with any grpc-specific options
119116
// sent to the client.

packages/google-cloud-videointelligence/src/v1beta2/video_intelligence_service_client.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,11 @@ export class VideoIntelligenceServiceClient {
106106
// const showcaseClient = new showcaseClient({ projectId, customConfig });
107107
opts.clientConfig = opts.clientConfig || {};
108108

109-
const isBrowser = typeof window !== 'undefined';
110-
if (isBrowser) {
111-
opts.fallback = true;
112-
}
113-
// If we are in browser, we are already using fallback because of the
114-
// "browser" field in package.json.
115-
// But if we were explicitly requested to use fallback, let's do it now.
116-
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
109+
// If we're running in browser, it's OK to omit `fallback` since
110+
// google-gax has `browser` field in its `package.json`.
111+
// For Electron (which does not respect `browser` field),
112+
// pass `{fallback: true}` to the VideoIntelligenceServiceClient constructor.
113+
this._gaxModule = opts.fallback ? gax.fallback : gax;
117114

118115
// Create a `gaxGrpc` object, with any grpc-specific options
119116
// sent to the client.

packages/google-cloud-videointelligence/src/v1p1beta1/video_intelligence_service_client.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,11 @@ export class VideoIntelligenceServiceClient {
106106
// const showcaseClient = new showcaseClient({ projectId, customConfig });
107107
opts.clientConfig = opts.clientConfig || {};
108108

109-
const isBrowser = typeof window !== 'undefined';
110-
if (isBrowser) {
111-
opts.fallback = true;
112-
}
113-
// If we are in browser, we are already using fallback because of the
114-
// "browser" field in package.json.
115-
// But if we were explicitly requested to use fallback, let's do it now.
116-
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
109+
// If we're running in browser, it's OK to omit `fallback` since
110+
// google-gax has `browser` field in its `package.json`.
111+
// For Electron (which does not respect `browser` field),
112+
// pass `{fallback: true}` to the VideoIntelligenceServiceClient constructor.
113+
this._gaxModule = opts.fallback ? gax.fallback : gax;
117114

118115
// Create a `gaxGrpc` object, with any grpc-specific options
119116
// sent to the client.

packages/google-cloud-videointelligence/src/v1p2beta1/video_intelligence_service_client.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,11 @@ export class VideoIntelligenceServiceClient {
106106
// const showcaseClient = new showcaseClient({ projectId, customConfig });
107107
opts.clientConfig = opts.clientConfig || {};
108108

109-
const isBrowser = typeof window !== 'undefined';
110-
if (isBrowser) {
111-
opts.fallback = true;
112-
}
113-
// If we are in browser, we are already using fallback because of the
114-
// "browser" field in package.json.
115-
// But if we were explicitly requested to use fallback, let's do it now.
116-
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
109+
// If we're running in browser, it's OK to omit `fallback` since
110+
// google-gax has `browser` field in its `package.json`.
111+
// For Electron (which does not respect `browser` field),
112+
// pass `{fallback: true}` to the VideoIntelligenceServiceClient constructor.
113+
this._gaxModule = opts.fallback ? gax.fallback : gax;
117114

118115
// Create a `gaxGrpc` object, with any grpc-specific options
119116
// sent to the client.

packages/google-cloud-videointelligence/src/v1p3beta1/streaming_video_intelligence_service_client.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,11 @@ export class StreamingVideoIntelligenceServiceClient {
9999
// const showcaseClient = new showcaseClient({ projectId, customConfig });
100100
opts.clientConfig = opts.clientConfig || {};
101101

102-
const isBrowser = typeof window !== 'undefined';
103-
if (isBrowser) {
104-
opts.fallback = true;
105-
}
106-
// If we are in browser, we are already using fallback because of the
107-
// "browser" field in package.json.
108-
// But if we were explicitly requested to use fallback, let's do it now.
109-
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
102+
// If we're running in browser, it's OK to omit `fallback` since
103+
// google-gax has `browser` field in its `package.json`.
104+
// For Electron (which does not respect `browser` field),
105+
// pass `{fallback: true}` to the StreamingVideoIntelligenceServiceClient constructor.
106+
this._gaxModule = opts.fallback ? gax.fallback : gax;
110107

111108
// Create a `gaxGrpc` object, with any grpc-specific options
112109
// sent to the client.

packages/google-cloud-videointelligence/src/v1p3beta1/video_intelligence_service_client.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,11 @@ export class VideoIntelligenceServiceClient {
106106
// const showcaseClient = new showcaseClient({ projectId, customConfig });
107107
opts.clientConfig = opts.clientConfig || {};
108108

109-
const isBrowser = typeof window !== 'undefined';
110-
if (isBrowser) {
111-
opts.fallback = true;
112-
}
113-
// If we are in browser, we are already using fallback because of the
114-
// "browser" field in package.json.
115-
// But if we were explicitly requested to use fallback, let's do it now.
116-
this._gaxModule = !isBrowser && opts.fallback ? gax.fallback : gax;
109+
// If we're running in browser, it's OK to omit `fallback` since
110+
// google-gax has `browser` field in its `package.json`.
111+
// For Electron (which does not respect `browser` field),
112+
// pass `{fallback: true}` to the VideoIntelligenceServiceClient constructor.
113+
this._gaxModule = opts.fallback ? gax.fallback : gax;
117114

118115
// Create a `gaxGrpc` object, with any grpc-specific options
119116
// sent to the client.

packages/google-cloud-videointelligence/synth.metadata

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"git": {
55
"name": ".",
66
"remote": "https://github.com/googleapis/nodejs-video-intelligence.git",
7-
"sha": "79f411801358ee081969f18db4c96308bd4b1eea"
7+
"sha": "eaee22cabed4bb31842196e0bcb2610daafc6f1c"
88
}
99
},
1010
{
@@ -19,7 +19,7 @@
1919
"git": {
2020
"name": "synthtool",
2121
"remote": "https://github.com/googleapis/synthtool.git",
22-
"sha": "1c92077459db3dc50741e878f98b08c6261181e0"
22+
"sha": "e7034945fbdc0e79d3c57f6e299e5c90b0f11469"
2323
}
2424
}
2525
],

0 commit comments

Comments
 (0)