Skip to content

Commit

Permalink
fix: Force use of http by the GAX module when using the GAX fallback …
Browse files Browse the repository at this point in the history
…and connecting to the emulator (#1788)

Force use of http by the GAX module when using the GAX fallback and connecting to the emulator.
  • Loading branch information
MarkDuckworth authored Oct 17, 2022
1 parent eb13505 commit 50747ad
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions dev/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as firestore from '@google-cloud/firestore';

import type {CallOptions} from 'google-gax';
import type {CallOptions, ClientOptions} from 'google-gax';
import type * as googleGax from 'google-gax';
import type * as googleGaxFallback from 'google-gax/build/src/fallback';
import {Duplex, PassThrough, Transform} from 'stream';
Expand Down Expand Up @@ -580,14 +580,19 @@ export class Firestore implements firestore.Firestore {
const grpcModule = this._settings.grpc ?? require('google-gax').grpc;
const sslCreds = grpcModule.credentials.createInsecure();

client = new module.exports.v1(
{
sslCreds,
...this._settings,
fallback: useFallback,
},
gax
);
const settings: ClientOptions = {
sslCreds,
...this._settings,
fallback: useFallback,
};

// Since `ssl === false`, if we're using the GAX fallback then
// also set the `protocol` option for GAX fallback to force http
if (useFallback) {
settings.protocol = 'http';
}

client = new module.exports.v1(settings, gax);
} else {
client = new module.exports.v1(
{
Expand Down

0 comments on commit 50747ad

Please sign in to comment.