Skip to content

Commit bbfd570

Browse files
authored
Fixed an issue where the VSCE extension used the wrong host for execution on Studio (#8849)
* Fixed an issue where the VSCE extension used the wrong host for execution on Studio * format * Fix overwriting issue
1 parent a3e87e5 commit bbfd570

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

firebase-vscode/src/options.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { RC } from "../../src/rc";
22
import { Options } from "../../src/options";
3-
import { Command } from "../../src/command";
43
import { ExtensionContext } from "vscode";
54
import { setInquirerOptions } from "./stubs/inquirer-stub";
65
import { Config } from "../../src/config";

src/emulator/env.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ export function maybeUsePortForwarding(i: EmulatorInfo): EmulatorInfo {
9797
}
9898
const url = `${info.port}-${portForwardingHost}`;
9999
info.host = url;
100-
info.listen = info.listen?.map((l) => {
100+
info.listen = info.listen?.map((listen) => {
101+
const l = { ...listen };
101102
l.address = url;
102103
l.port = 443;
103104
return l;

src/emulator/hub.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { ExpressBasedEmulator } from "./ExpressBasedEmulator";
1313
import { PortName } from "./portUtils";
1414
import { DataConnectEmulator } from "./dataconnectEmulator";
1515
import { isVSCodeExtension } from "../vsCodeUtils";
16-
import { maybeUsePortForwarding } from "./env";
1716

1817
// We use the CLI version from package.json
1918
const pkg = require("../../package.json");
@@ -83,10 +82,10 @@ export class EmulatorHub extends ExpressBasedEmulator {
8382
getRunningEmulatorsMapping(): GetEmulatorsResponse {
8483
const emulators: GetEmulatorsResponse = {};
8584
for (const info of EmulatorRegistry.listRunningWithInfo()) {
86-
emulators[info.name] = maybeUsePortForwarding({
85+
emulators[info.name] = {
8786
listen: this.args.listenForEmulator[info.name],
8887
...info,
89-
});
88+
};
9089
}
9190
return emulators;
9291
}

src/emulator/ui.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { AnalyticsSession, emulatorSession } from "../track";
1010
import { ExpressBasedEmulator } from "./ExpressBasedEmulator";
1111
import { ALL_EXPERIMENTS, ExperimentName, isEnabled } from "../experiments";
1212
import { EmulatorHub, GetEmulatorsResponse } from "./hub";
13+
import { mapObject } from "../functional";
14+
import { maybeUsePortForwarding } from "./env";
1315

1416
export interface EmulatorUIOptions {
1517
listen: ListenSpec[];
@@ -60,7 +62,10 @@ export class EmulatorUI extends ExpressBasedEmulator {
6062
app.get(
6163
"/api/config",
6264
this.jsonHandler(() => {
63-
const emulatorInfos = (hub! as EmulatorHub).getRunningEmulatorsMapping();
65+
const emulatorInfos = mapObject(
66+
(hub! as EmulatorHub).getRunningEmulatorsMapping(),
67+
maybeUsePortForwarding,
68+
);
6469
const json: EmulatorConfigInfo = {
6570
projectId,
6671
experiments: enabledExperiments ?? [],

0 commit comments

Comments
 (0)