Skip to content

Commit 50747ad

Browse files
fix: Force use of http by the GAX module when using the GAX fallback and connecting to the emulator (#1788)
Force use of http by the GAX module when using the GAX fallback and connecting to the emulator.
1 parent eb13505 commit 50747ad

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

dev/src/index.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

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

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

583-
client = new module.exports.v1(
584-
{
585-
sslCreds,
586-
...this._settings,
587-
fallback: useFallback,
588-
},
589-
gax
590-
);
583+
const settings: ClientOptions = {
584+
sslCreds,
585+
...this._settings,
586+
fallback: useFallback,
587+
};
588+
589+
// Since `ssl === false`, if we're using the GAX fallback then
590+
// also set the `protocol` option for GAX fallback to force http
591+
if (useFallback) {
592+
settings.protocol = 'http';
593+
}
594+
595+
client = new module.exports.v1(settings, gax);
591596
} else {
592597
client = new module.exports.v1(
593598
{

0 commit comments

Comments
 (0)