Skip to content

Commit aecf87c

Browse files
fix: handle fallback option properly (#608)
* 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 <[email protected]> Source-Author: BenWhitehead <[email protected]> Source-Date: Wed Jun 10 22:24:28 2020 -0400 Source-Repo: googleapis/synthtool Source-Sha: e7034945fbdc0e79d3c57f6e299e5c90b0f11469 Source-Link: googleapis/synthtool@e703494
1 parent a777f81 commit aecf87c

File tree

3 files changed

+12
-18
lines changed

3 files changed

+12
-18
lines changed

packages/google-cloud-speech/src/v1/speech_client.ts

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

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

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

packages/google-cloud-speech/src/v1p1beta1/speech_client.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,11 @@ export class SpeechClient {
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 SpeechClient 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-speech/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-speech.git",
7-
"sha": "3af749c8f705d92dba12169ba97c176ff3006a31"
7+
"sha": "e3ac050fc99adf0907b29fe8ef54c24037dc7229"
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)