Skip to content

Commit 34b9fe2

Browse files
fix: ensure gax is usable from electron (#475)
1 parent c8b4d68 commit 34b9fe2

File tree

3 files changed

+11
-17
lines changed

3 files changed

+11
-17
lines changed

packages/google-cloud-language/src/v1/language_service_client.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,11 @@ export class LanguageServiceClient {
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 LanguageServiceClient 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-language/src/v1beta2/language_service_client.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,11 @@ export class LanguageServiceClient {
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 LanguageServiceClient 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-language/synth.metadata

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"git": {
55
"name": ".",
66
"remote": "https://github.com/googleapis/nodejs-language.git",
7-
"sha": "df4d71c7a3c6a4b02fb48ee5cfed76f795a446ea"
7+
"sha": "3c67c269d13636e9e645e4fdca50d312202abcfd"
88
}
99
},
1010
{

0 commit comments

Comments
 (0)