Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update remaining test targets to use undici #7761

Merged
merged 13 commits into from
Nov 10, 2023
Prev Previous commit
Next Next commit
revert undici in emulator.ts
  • Loading branch information
DellaBitta committed Nov 10, 2023
commit b0f4c599d02cd87a6e063b8efcf7beb975fe8455
13 changes: 4 additions & 9 deletions scripts/emulator-testing/emulators/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { ChildProcess } from 'child_process';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { fetch as undiciFetch } from 'undici';
import fetch from 'node-fetch';
// @ts-ignore
import * as tmp from 'tmp';

Expand Down Expand Up @@ -55,16 +55,11 @@ export abstract class Emulator {
console.log(`Created temporary directory at [${dir}].`);
const filepath: string = path.resolve(dir, this.binaryName);
const writeStream: fs.WriteStream = fs.createWriteStream(filepath);
const writableStream = new WritableStream({
write(chunk) {
writeStream.write(chunk);
},
});

console.log(`Downloading emulator from [${this.binaryUrl}] ...`);
undiciFetch(this.binaryUrl).then(resp => {
fetch(this.binaryUrl).then(resp => {
resp.body
.pipeTo(writableStream)
.pipe(writeStream)
.on('finish', () => {
console.log(`Saved emulator binary file to [${filepath}].`);
// Change emulator binary file permission to 'rwxr-xr-x'.
Expand Down Expand Up @@ -125,7 +120,7 @@ export abstract class Emulator {
reject(`Emulator not ready after ${timeout}s. Exiting ...`);
} else {
console.log(`Ping emulator at [http://localhost:${this.port}] ...`);
undiciFetch(`http://localhost:${this.port}`).then(
fetch(`http://localhost:${this.port}`).then(
() => {
// Database and Firestore emulators will return 400 and 200 respectively.
// As long as we get a response back, it means the emulator is ready.
Expand Down