Skip to content

Commit 116ea1e

Browse files
committed
Migrate the other request call to fetch.
1 parent 30b241a commit 116ea1e

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

scripts/emulator-testing/emulators/emulator.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,17 @@ export abstract class Emulator {
120120
reject(`Emulator not ready after ${timeout}s. Exiting ...`);
121121
} else {
122122
console.log(`Ping emulator at [http://localhost:${this.port}] ...`);
123-
request(`http://localhost:${this.port}`, (error, response) => {
124-
if (error && error.code === 'ECONNREFUSED') {
125-
setTimeout(wait, 1000, resolve, reject);
126-
} else if (response) {
123+
fetch(`http://localhost:${this.port}`).then(
124+
() => {
127125
// Database and Firestore emulators will return 400 and 200 respectively.
128126
// As long as we get a response back, it means the emulator is ready.
129127
console.log(`Emulator has started up after ${elapsed}s!`);
130128
resolve();
131-
} else {
132-
// This should not happen.
133-
reject({ error, response });
129+
},
130+
error => {
131+
setTimeout(wait, 1000, resolve, reject);
134132
}
135-
});
133+
);
136134
}
137135
};
138136
setTimeout(wait, 1000, resolve, reject);

0 commit comments

Comments
 (0)