Skip to content

Commit eeadf56

Browse files
joehanmathu97
authored andcommitted
Fixing emulator timeout issues (#7092)
* Fixing emulator timeout issues * Joe learns how to spell waiting
1 parent d027d48 commit eeadf56

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Increased the timeout for waiting for emulators to start to 60s. (#7091)

src/emulator/dataconnectEmulator.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export class DataConnectEmulator implements EmulatorInstance {
6969
host,
7070
port,
7171
pid: getPID(Emulators.DATACONNECT),
72+
timeout: 10_000,
7273
};
7374
}
7475
getName(): Emulators {

src/emulator/portUtils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,14 @@ export async function checkListenable(
160160
}
161161

162162
/**
163-
* Wait for a port to be available on the given host. Checks every 250ms for up to 5s.
163+
* Wait for a port to be available on the given host. Checks every 250ms for up to timeout (default 60s).
164164
*/
165-
export async function waitForPortUsed(port: number, host: string): Promise<void> {
165+
export async function waitForPortUsed(
166+
port: number,
167+
host: string,
168+
timeout: number = 60_000,
169+
): Promise<void> {
166170
const interval = 200;
167-
const timeout = 5_000;
168171
try {
169172
await tcpport.waitUntilUsedOnHost(port, host, interval, timeout);
170173
} catch (e: any) {

src/emulator/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class EmulatorRegistry {
3535
// No need to wait for the Extensions emulator to close its port, since it runs on the Functions emulator.
3636
if (instance.getName() !== Emulators.EXTENSIONS) {
3737
const info = instance.getInfo();
38-
await portUtils.waitForPortUsed(info.port, connectableHostname(info.host));
38+
await portUtils.waitForPortUsed(info.port, connectableHostname(info.host), info.timeout);
3939
}
4040
}
4141

src/emulator/types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,15 @@ export interface EmulatorInfo {
138138
pid?: number;
139139
reservedPorts?: number[];
140140

141-
/** All addresses that an emulator listens on. */
141+
// All addresses that an emulator listens on.
142142
listen?: ListenSpec[];
143143

144-
/** The primary IP address that the emulator listens on. */
144+
// The primary IP address that the emulator listens on.
145145
host: string;
146146
port: number;
147+
148+
// How long to wait for the emulator to start before erroring out.
149+
timeout?: number;
147150
}
148151

149152
export interface DownloadableEmulatorCommand {

0 commit comments

Comments
 (0)