From 4bdab6fa6af32f9d1b6c66437cce126ae0508c9e Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Tue, 10 Sep 2024 11:21:27 -0400 Subject: [PATCH 01/34] Removed node-fetch from rules-unit-testing --- packages/rules-unit-testing/package.json | 4 ---- packages/rules-unit-testing/src/impl/discovery.ts | 5 ++--- packages/rules-unit-testing/src/impl/rules.ts | 1 - packages/rules-unit-testing/src/impl/test_environment.ts | 1 - packages/rules-unit-testing/src/util.ts | 1 - packages/rules-unit-testing/test/impl/discovery.test.ts | 2 +- packages/rules-unit-testing/test/util.test.ts | 4 ++-- scripts/emulator-testing/emulators/emulator.ts | 1 - 8 files changed, 5 insertions(+), 14 deletions(-) diff --git a/packages/rules-unit-testing/package.json b/packages/rules-unit-testing/package.json index 4053cca8e17..585a0efc5e8 100644 --- a/packages/rules-unit-testing/package.json +++ b/packages/rules-unit-testing/package.json @@ -53,9 +53,5 @@ "typings": "dist/index.d.ts", "bugs": { "url": "https://github.com/firebase/firebase-js-sdk/issues" - }, - "dependencies": { - "node-fetch": "2.6.7", - "@types/node-fetch": "2.6.4" } } diff --git a/packages/rules-unit-testing/src/impl/discovery.ts b/packages/rules-unit-testing/src/impl/discovery.ts index 9798f017241..3c7c20fedad 100644 --- a/packages/rules-unit-testing/src/impl/discovery.ts +++ b/packages/rules-unit-testing/src/impl/discovery.ts @@ -16,7 +16,6 @@ */ import { EmulatorConfig, HostAndPort } from '../public_types'; -import nodeFetch from 'node-fetch'; import { makeUrl, fixHostname } from './url'; /** @@ -27,9 +26,9 @@ import { makeUrl, fixHostname } from './url'; */ export async function discoverEmulators( hub: HostAndPort, - fetch: typeof nodeFetch = nodeFetch + fetchImpl: typeof fetch = fetch ): Promise { - const res = await fetch(makeUrl(hub, '/emulators')); + const res = await fetchImpl(makeUrl(hub, '/emulators')); if (!res.ok) { throw new Error( `HTTP Error ${res.status} when attempting to reach Emulator Hub at ${res.url}, are you sure it is running?` diff --git a/packages/rules-unit-testing/src/impl/rules.ts b/packages/rules-unit-testing/src/impl/rules.ts index 7d4d900367f..fefeb586233 100644 --- a/packages/rules-unit-testing/src/impl/rules.ts +++ b/packages/rules-unit-testing/src/impl/rules.ts @@ -17,7 +17,6 @@ import { HostAndPort } from '../public_types'; import { makeUrl } from './url'; -import fetch from 'node-fetch'; /** * @private diff --git a/packages/rules-unit-testing/src/impl/test_environment.ts b/packages/rules-unit-testing/src/impl/test_environment.ts index cb325912c29..5e0f4c613fe 100644 --- a/packages/rules-unit-testing/src/impl/test_environment.ts +++ b/packages/rules-unit-testing/src/impl/test_environment.ts @@ -15,7 +15,6 @@ * limitations under the License. */ -import fetch from 'node-fetch'; import firebase from 'firebase/compat/app'; import 'firebase/compat/firestore'; import 'firebase/compat/database'; diff --git a/packages/rules-unit-testing/src/util.ts b/packages/rules-unit-testing/src/util.ts index c96b22d8597..abcad41ef9b 100644 --- a/packages/rules-unit-testing/src/util.ts +++ b/packages/rules-unit-testing/src/util.ts @@ -21,7 +21,6 @@ import { } from './impl/discovery'; import { fixHostname, makeUrl } from './impl/url'; import { HostAndPort } from './public_types'; -import fetch from 'node-fetch'; /** * Run a setup function with background Cloud Functions triggers disabled. This can be used to diff --git a/packages/rules-unit-testing/test/impl/discovery.test.ts b/packages/rules-unit-testing/test/impl/discovery.test.ts index a2ac2be767b..39b5628ddc2 100644 --- a/packages/rules-unit-testing/test/impl/discovery.test.ts +++ b/packages/rules-unit-testing/test/impl/discovery.test.ts @@ -71,7 +71,7 @@ describe('discoverEmulators()', () => { // Connect to port:0. Should always fail (although error codes may differ among OSes). await expect( discoverEmulators({ host: '127.0.0.1', port: 0 }) - ).to.be.rejectedWith(/EADDRNOTAVAIL|ECONNREFUSED/); + ).to.be.rejectedWith(/EADDRNOTAVAIL|ECONNREFUSED|fetch failed/); }); it('throws if response status is not 2xx', async () => { diff --git a/packages/rules-unit-testing/test/util.test.ts b/packages/rules-unit-testing/test/util.test.ts index 9dc778fb93e..e3b514d6a10 100644 --- a/packages/rules-unit-testing/test/util.test.ts +++ b/packages/rules-unit-testing/test/util.test.ts @@ -165,7 +165,7 @@ describe('assertFails()', () => { describe('withFunctionTriggersDisabled()', () => { it('disabling function triggers does not throw, returns value', async function () { - const fetchSpy = sinon.spy(require('node-fetch'), 'default'); + const fetchSpy = sinon.spy(globalThis, 'fetch'); const res = await withFunctionTriggersDisabled(() => { return Promise.resolve(1234); @@ -176,7 +176,7 @@ describe('withFunctionTriggersDisabled()', () => { }); it('disabling function triggers always re-enables, event when the function throws', async function () { - const fetchSpy = sinon.spy(require('node-fetch'), 'default'); + const fetchSpy = sinon.spy(globalThis, 'fetch'); const res = withFunctionTriggersDisabled(() => { throw new Error('I throw!'); diff --git a/scripts/emulator-testing/emulators/emulator.ts b/scripts/emulator-testing/emulators/emulator.ts index 1295d413e4b..7563467de4f 100644 --- a/scripts/emulator-testing/emulators/emulator.ts +++ b/scripts/emulator-testing/emulators/emulator.ts @@ -21,7 +21,6 @@ import { ChildProcess } from 'child_process'; import * as fs from 'fs'; import * as os from 'os'; import * as path from 'path'; -import fetch from 'node-fetch'; // @ts-ignore import * as tmp from 'tmp'; From 45723bbdd81aaed6011e3e8063bf027e5171943f Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Wed, 11 Sep 2024 16:24:37 -0400 Subject: [PATCH 02/34] Draft emulator impl not quite working. --- .../emulator-testing/emulators/emulator.ts | 59 +++++++++++-------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/scripts/emulator-testing/emulators/emulator.ts b/scripts/emulator-testing/emulators/emulator.ts index 7563467de4f..8e16dfdcdf7 100644 --- a/scripts/emulator-testing/emulators/emulator.ts +++ b/scripts/emulator-testing/emulators/emulator.ts @@ -23,6 +23,7 @@ import * as os from 'os'; import * as path from 'path'; // @ts-ignore import * as tmp from 'tmp'; +import { Readable } from "stream"; export abstract class Emulator { binaryPath: string | null = null; @@ -40,6 +41,9 @@ export abstract class Emulator { this.cacheBinaryPath = path.join(this.cacheDirectory, binaryName); } + setBinaryPath(path: string) { + this.binaryPath = path; + } download(): Promise { if (fs.existsSync(this.cacheBinaryPath)) { console.log(`Emulator found in cache: ${this.cacheBinaryPath}`); @@ -50,35 +54,38 @@ export abstract class Emulator { return new Promise((resolve, reject) => { tmp.dir((err: Error | null, dir: string) => { if (err) reject(err); - console.log(`Created temporary directory at [${dir}].`); const filepath: string = path.resolve(dir, this.binaryName); - const writeStream: fs.WriteStream = fs.createWriteStream(filepath); - + const writer = fs.createWriteStream(filepath); console.log(`Downloading emulator from [${this.binaryUrl}] ...`); - fetch(this.binaryUrl).then(resp => { - resp.body - .pipe(writeStream) - .on('finish', () => { - console.log(`Saved emulator binary file to [${filepath}].`); - // Change emulator binary file permission to 'rwxr-xr-x'. - // The execute permission is required for it to be able to start - // with 'java -jar'. - fs.chmod(filepath, 0o755, err => { - if (err) reject(err); - console.log( - `Changed emulator file permissions to 'rwxr-xr-x'.` - ); - this.binaryPath = filepath; - - if (this.copyToCache()) { - console.log(`Cached emulator at ${this.cacheBinaryPath}`); - } - resolve(); - }); - }) - .on('error', reject); - }); + try { + fetch(this.binaryUrl).then(resp => { + const reader = resp.body?.getReader(); + reader?.read().then(function readStuff(this: Emulator, { done, value }): any { + if (done) { + console.log(`Saved emulator binary file to [${filepath}].`); + // Change emulator binary file permission to 'rwxr-xr-x'. + // The execute permission is required for it to be able to start + // with 'java -jar'. + fs.chmod(filepath, 0o755, err => { + if (err) reject(err); + console.log(`Changed emulator file permissions to 'rwxr-xr-x'.`); + (this as Emulator).setBinaryPath(filepath);//this.binaryPath = filepath; + if (this.copyToCache()) { + console.log(`Cached emulator at ${this.cacheBinaryPath}`); + } + resolve(); + }); + } else { + writer.write(value); + return reader.read().then(readStuff); + } + }); + }); + } catch (e) { + console.log(`Download of emulator failed: ${e}`); + reject(); + } }); }); } From 5ee8eb7fdc34925d3f97fdb5c003e3e6d8d45126 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Wed, 11 Sep 2024 17:55:14 -0400 Subject: [PATCH 03/34] Wrap the emulator download in a promise --- .../emulator-testing/emulators/emulator.ts | 53 +++++++++---------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/scripts/emulator-testing/emulators/emulator.ts b/scripts/emulator-testing/emulators/emulator.ts index 8e16dfdcdf7..b17bf292edd 100644 --- a/scripts/emulator-testing/emulators/emulator.ts +++ b/scripts/emulator-testing/emulators/emulator.ts @@ -58,34 +58,33 @@ export abstract class Emulator { const filepath: string = path.resolve(dir, this.binaryName); const writer = fs.createWriteStream(filepath); console.log(`Downloading emulator from [${this.binaryUrl}] ...`); - try { - fetch(this.binaryUrl).then(resp => { - const reader = resp.body?.getReader(); - reader?.read().then(function readStuff(this: Emulator, { done, value }): any { - if (done) { - console.log(`Saved emulator binary file to [${filepath}].`); - // Change emulator binary file permission to 'rwxr-xr-x'. - // The execute permission is required for it to be able to start - // with 'java -jar'. - fs.chmod(filepath, 0o755, err => { - if (err) reject(err); - console.log(`Changed emulator file permissions to 'rwxr-xr-x'.`); - (this as Emulator).setBinaryPath(filepath);//this.binaryPath = filepath; - if (this.copyToCache()) { - console.log(`Cached emulator at ${this.cacheBinaryPath}`); - } - resolve(); - }); - } else { - writer.write(value); - return reader.read().then(readStuff); - } + const downloadPromise = new Promise((downloadComplete, downloadFailed) => { + try { + fetch(this.binaryUrl).then(resp => { + const reader = resp.body?.getReader(); + reader?.read().then(function readStuff({ done, value }): any { + if (done) { + downloadComplete; + } else { + writer.write(value); + return reader.read().then(readStuff); + } + }); }); - }); - } catch (e) { - console.log(`Download of emulator failed: ${e}`); - reject(); - } + } catch (e) { + console.log(`Download of emulator failed: ${e}`); + downloadFailed(); + } + }); + downloadPromise.then(() => { + this.binaryPath = filepath; + if (this.copyToCache()) { + console.log(`Cached emulator at ${this.cacheBinaryPath}`); + } + resolve; + }, () => { + reject; + }); }); }); } From 84f0770c52979949876e95ddf8ec7b12faed279c Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 12 Sep 2024 08:24:56 -0400 Subject: [PATCH 04/34] Update yarn.lock --- yarn.lock | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/yarn.lock b/yarn.lock index 477e784871e..f80f8bbefef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3480,14 +3480,6 @@ dependencies: "@types/node" "*" -"@types/node-fetch@2.6.4": - version "2.6.4" - resolved "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.4.tgz" - integrity sha512-1ZX9fcN4Rvkvgv4E6PAY5WXUFWFcRWxZa3EW83UjycOB9ljJCedb2CupIP4RZMEwF/M3eTcCihbBRgwtGbg5Rg== - dependencies: - "@types/node" "*" - form-data "^3.0.0" - "@types/node@*", "@types/node@>=10.0.0", "@types/node@^12.7.1": version "12.20.50" resolved "https://registry.npmjs.org/@types/node/-/node-12.20.50.tgz" @@ -8512,15 +8504,6 @@ form-data@^2.5.0: combined-stream "^1.0.6" mime-types "^2.1.12" -form-data@^3.0.0: - version "3.0.1" - resolved "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz" - integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - form-data@^4.0.0: version "4.0.0" resolved "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz" @@ -12852,13 +12835,6 @@ node-emoji@^1.11.0: dependencies: lodash "^4.17.21" -node-fetch@2.6.7, node-fetch@^2.6.7: - version "2.6.7" - resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz" - integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== - dependencies: - whatwg-url "^5.0.0" - node-fetch@^2.5.0, node-fetch@^2.6.1: version "2.6.5" resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.5.tgz" @@ -12866,6 +12842,13 @@ node-fetch@^2.5.0, node-fetch@^2.6.1: dependencies: whatwg-url "^5.0.0" +node-fetch@^2.6.7: + version "2.6.7" + resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz" + integrity sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ== + dependencies: + whatwg-url "^5.0.0" + node-forge@^0.10.0: version "0.10.0" resolved "https://registry.npmjs.org/node-forge/-/node-forge-0.10.0.tgz" From afea52d673e05548ca79967a701e78306b4175ac Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 12 Sep 2024 09:07:12 -0400 Subject: [PATCH 05/34] emulator.ts reject/resolve fix. formatting. --- .../emulator-testing/emulators/emulator.ts | 61 +++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/scripts/emulator-testing/emulators/emulator.ts b/scripts/emulator-testing/emulators/emulator.ts index b17bf292edd..9f9c9b6d5f9 100644 --- a/scripts/emulator-testing/emulators/emulator.ts +++ b/scripts/emulator-testing/emulators/emulator.ts @@ -23,7 +23,6 @@ import * as os from 'os'; import * as path from 'path'; // @ts-ignore import * as tmp from 'tmp'; -import { Readable } from "stream"; export abstract class Emulator { binaryPath: string | null = null; @@ -58,33 +57,47 @@ export abstract class Emulator { const filepath: string = path.resolve(dir, this.binaryName); const writer = fs.createWriteStream(filepath); console.log(`Downloading emulator from [${this.binaryUrl}] ...`); - const downloadPromise = new Promise((downloadComplete, downloadFailed) => { - try { - fetch(this.binaryUrl).then(resp => { - const reader = resp.body?.getReader(); - reader?.read().then(function readStuff({ done, value }): any { - if (done) { - downloadComplete; - } else { - writer.write(value); - return reader.read().then(readStuff); + // Map the DOM's fetch Reader to node's streaming file system + // operations. + const downloadPromise = new Promise( + (downloadComplete, downloadFailed) => { + fetch(this.binaryUrl) + .then(resp => { + if (resp.status !== 200) { + console.log('Download of emulator failed: ', resp.statusText); + downloadFailed(); } + const reader = resp.body?.getReader(); + reader?.read().then(function readChunk({ done, value }): any { + if (done) { + downloadComplete(); + } else { + writer.write(value); + return reader.read().then(readChunk); + } + }); + }) + .catch(e => { + console.log(`Download of emulator failed: ${e}`); + downloadFailed(); }); - }); - } catch (e) { - console.log(`Download of emulator failed: ${e}`); - downloadFailed(); } - }); - downloadPromise.then(() => { - this.binaryPath = filepath; - if (this.copyToCache()) { - console.log(`Cached emulator at ${this.cacheBinaryPath}`); + ); + // Copy to cache when the download completes, and resolve + // the promise returned by this method. + downloadPromise.then( + () => { + console.log('Download complete'); + this.binaryPath = filepath; + if (this.copyToCache()) { + console.log(`Cached emulator at ${this.cacheBinaryPath}`); + } + resolve(); + }, + () => { + reject(); } - resolve; - }, () => { - reject; - }); + ); }); }); } From 79753b263c0fbb9c733f61bc323ec8d1bce8f0ad Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 12 Sep 2024 09:19:23 -0400 Subject: [PATCH 06/34] Update emaultor.ts with chmod operation. --- .../emulator-testing/emulators/emulator.ts | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/scripts/emulator-testing/emulators/emulator.ts b/scripts/emulator-testing/emulators/emulator.ts index 9f9c9b6d5f9..51c15b1960f 100644 --- a/scripts/emulator-testing/emulators/emulator.ts +++ b/scripts/emulator-testing/emulators/emulator.ts @@ -83,16 +83,22 @@ export abstract class Emulator { }); } ); - // Copy to cache when the download completes, and resolve - // the promise returned by this method. + downloadPromise.then( () => { console.log('Download complete'); - this.binaryPath = filepath; - if (this.copyToCache()) { - console.log(`Cached emulator at ${this.cacheBinaryPath}`); - } - resolve(); + // Change emulator binary file permission to 'rwxr-xr-x'. + // The execute permission is required for it to be able to start + // with 'java -jar'. + fs.chmod(filepath, 0o755, err => { + if (err) reject(err); + console.log(`Changed emulator file permissions to 'rwxr-xr-x'.`); + this.binaryPath = filepath; + if (this.copyToCache()) { + console.log(`Cached emulator at ${this.cacheBinaryPath}`); + } + resolve(); + }); }, () => { reject(); From ba32125811ec251ba8ca51ee5e972062a62d01b5 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 12 Sep 2024 10:34:09 -0400 Subject: [PATCH 07/34] emulator.ts remove setBinaryPath & add comments. --- scripts/emulator-testing/emulators/emulator.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/emulator-testing/emulators/emulator.ts b/scripts/emulator-testing/emulators/emulator.ts index 51c15b1960f..fa6059706a6 100644 --- a/scripts/emulator-testing/emulators/emulator.ts +++ b/scripts/emulator-testing/emulators/emulator.ts @@ -40,9 +40,6 @@ export abstract class Emulator { this.cacheBinaryPath = path.join(this.cacheDirectory, binaryName); } - setBinaryPath(path: string) { - this.binaryPath = path; - } download(): Promise { if (fs.existsSync(this.cacheBinaryPath)) { console.log(`Emulator found in cache: ${this.cacheBinaryPath}`); @@ -58,7 +55,9 @@ export abstract class Emulator { const writer = fs.createWriteStream(filepath); console.log(`Downloading emulator from [${this.binaryUrl}] ...`); // Map the DOM's fetch Reader to node's streaming file system - // operations. + // operations. We will need to access class members `binaryPath` and `copyToCache` after the + // download completes. It's a compilation error to pass `this` into the named function + // `readChunk`, so the download operation is wrapped in a promise that we wait upon. const downloadPromise = new Promise( (downloadComplete, downloadFailed) => { fetch(this.binaryUrl) From 6fdd75865711edd591dee0fd279ff54bf1a3bce1 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 12 Sep 2024 11:51:08 -0400 Subject: [PATCH 08/34] Remove undici from messaging testing --- integration/messaging/package.json | 1 - integration/messaging/test/utils/sendMessage.js | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/integration/messaging/package.json b/integration/messaging/package.json index 864faa99987..f34637fba05 100644 --- a/integration/messaging/package.json +++ b/integration/messaging/package.json @@ -15,7 +15,6 @@ "express": "4.19.2", "geckodriver": "2.0.4", "mocha": "9.2.2", - "undici": "6.19.7", "selenium-assistant": "6.1.1" }, "engines": { diff --git a/integration/messaging/test/utils/sendMessage.js b/integration/messaging/test/utils/sendMessage.js index 1d2e95054eb..6393e90364c 100644 --- a/integration/messaging/test/utils/sendMessage.js +++ b/integration/messaging/test/utils/sendMessage.js @@ -15,7 +15,6 @@ * limitations under the License. */ -const undici = require('undici'); const FCM_SEND_ENDPOINT = 'https://fcm.googleapis.com/fcm/send'; // Rotatable fcm server key. It's generally a bad idea to expose server keys. The reason is to // simplify testing process (no need to implement server side decryption of git secret). The @@ -28,7 +27,7 @@ module.exports = async payload => { 'Requesting to send an FCM message with payload: ' + JSON.stringify(payload) ); - const response = await undici.fetch(FCM_SEND_ENDPOINT, { + const response = await fetch(FCM_SEND_ENDPOINT, { method: 'POST', body: JSON.stringify(payload), headers: { From 0601594d38930fba3b736eaf4cdb55f2fb365bec Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 12 Sep 2024 11:52:28 -0400 Subject: [PATCH 09/34] Remove undici from auth source and package.json --- packages/auth-compat/index.node.ts | 11 +++-------- packages/auth-compat/package.json | 1 - packages/auth/package.json | 1 - packages/auth/src/platform_node/index.ts | 11 +++-------- .../test/helpers/integration/emulator_rest_helpers.ts | 5 ++--- 5 files changed, 8 insertions(+), 21 deletions(-) diff --git a/packages/auth-compat/index.node.ts b/packages/auth-compat/index.node.ts index 6d8dd2c07a5..7ab2677c060 100644 --- a/packages/auth-compat/index.node.ts +++ b/packages/auth-compat/index.node.ts @@ -23,15 +23,10 @@ */ export * from './index'; import { FetchProvider } from '@firebase/auth/internal'; -import { - fetch as undiciFetch, - Headers as undiciHeaders, - Response as undiciResponse -} from 'undici'; import './index'; FetchProvider.initialize( - undiciFetch as unknown as typeof fetch, - undiciHeaders as unknown as typeof Headers, - undiciResponse as unknown as typeof Response + fetch as unknown as typeof fetch, + Headers as unknown as typeof Headers, + Response as unknown as typeof Response ); diff --git a/packages/auth-compat/package.json b/packages/auth-compat/package.json index 6db6e7ba89d..d6d5d9573b8 100644 --- a/packages/auth-compat/package.json +++ b/packages/auth-compat/package.json @@ -55,7 +55,6 @@ "@firebase/auth-types": "0.12.2", "@firebase/component": "0.6.8", "@firebase/util": "1.9.7", - "undici": "6.19.7", "tslib": "^2.1.0" }, "license": "Apache-2.0", diff --git a/packages/auth/package.json b/packages/auth/package.json index 7d41b0c5962..2dff1631c02 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -130,7 +130,6 @@ "@firebase/component": "0.6.8", "@firebase/logger": "0.4.2", "@firebase/util": "1.9.7", - "undici": "6.19.7", "tslib": "^2.1.0" }, "license": "Apache-2.0", diff --git a/packages/auth/src/platform_node/index.ts b/packages/auth/src/platform_node/index.ts index 41da18ff643..d0c7425a350 100644 --- a/packages/auth/src/platform_node/index.ts +++ b/packages/auth/src/platform_node/index.ts @@ -28,17 +28,12 @@ import { AuthImpl } from '../core/auth/auth_impl'; import { FetchProvider } from '../core/util/fetch_provider'; import { getDefaultEmulatorHost } from '@firebase/util'; -import { - fetch as undiciFetch, - Headers as undiciHeaders, - Response as undiciResponse -} from 'undici'; // Initialize the fetch polyfill, the types are slightly off so just cast and hope for the best FetchProvider.initialize( - undiciFetch as unknown as typeof fetch, - undiciHeaders as unknown as typeof Headers, - undiciResponse as unknown as typeof Response + fetch as unknown as typeof fetch, + Headers as unknown as typeof Headers, + Response as unknown as typeof Response ); // First, we set up the various platform-specific features for Node (register diff --git a/packages/auth/test/helpers/integration/emulator_rest_helpers.ts b/packages/auth/test/helpers/integration/emulator_rest_helpers.ts index 32b9aad2129..55eb4ea927e 100644 --- a/packages/auth/test/helpers/integration/emulator_rest_helpers.ts +++ b/packages/auth/test/helpers/integration/emulator_rest_helpers.ts @@ -15,7 +15,6 @@ * limitations under the License. */ -import { fetch as undiciFetch, RequestInit as undiciRequestInit } from 'undici'; import { getAppConfig, getEmulatorUrl } from './settings'; export interface VerificationSession { @@ -88,9 +87,9 @@ function doFetch(url: string, request?: RequestInit): ReturnType { if (typeof document !== 'undefined') { return fetch(url, request); } else { - return undiciFetch( + return fetch( url, - request as undiciRequestInit + request as RequestInit ) as unknown as ReturnType; } } From 2c4a46e86f69fd84aba5ac52a50b60486fb7406a Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 12 Sep 2024 16:58:56 -0400 Subject: [PATCH 10/34] auth format --- .../auth/test/helpers/integration/emulator_rest_helpers.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/auth/test/helpers/integration/emulator_rest_helpers.ts b/packages/auth/test/helpers/integration/emulator_rest_helpers.ts index 55eb4ea927e..5a96d193ee1 100644 --- a/packages/auth/test/helpers/integration/emulator_rest_helpers.ts +++ b/packages/auth/test/helpers/integration/emulator_rest_helpers.ts @@ -87,9 +87,8 @@ function doFetch(url: string, request?: RequestInit): ReturnType { if (typeof document !== 'undefined') { return fetch(url, request); } else { - return fetch( - url, - request as RequestInit - ) as unknown as ReturnType; + return fetch(url, request as RequestInit) as unknown as ReturnType< + typeof fetch + >; } } From 3b93ffe54055a41c22690222346acf3c37091e00 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 12 Sep 2024 16:59:08 -0400 Subject: [PATCH 11/34] repo-scripts --- repo-scripts/changelog-generator/index.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/repo-scripts/changelog-generator/index.ts b/repo-scripts/changelog-generator/index.ts index 20f3de482f1..3570c8a96a5 100644 --- a/repo-scripts/changelog-generator/index.ts +++ b/repo-scripts/changelog-generator/index.ts @@ -17,7 +17,6 @@ import { ChangelogFunctions } from '@changesets/types'; import { getInfo } from '@changesets/get-github-info'; -import { fetch as undiciFetch, Response as undiciResponse } from 'undici'; const changelogFunctions: ChangelogFunctions = { getDependencyReleaseLine: async ( @@ -95,7 +94,7 @@ async function getFixedIssueLink( prNumber: number, repo: string ): Promise { - const response = await undiciFetch( + const response = await fetch( `https://api.github.com/repos/${repo}/pulls/${prNumber}`, { method: 'GET', @@ -105,7 +104,7 @@ async function getFixedIssueLink( } ).then(data => data.json()); - const body = (response as undiciResponse).body; + const body = (response as Response).body; if (!body) { return ''; } From 97eb7a328de5a350d5e499ffebdfd05a1ac1b7e3 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 12 Sep 2024 17:13:37 -0400 Subject: [PATCH 12/34] Auth: remove custom webpack step for undici --- packages/auth-compat/karma.conf.js | 12 ------------ packages/auth/karma.conf.js | 11 ----------- 2 files changed, 23 deletions(-) diff --git a/packages/auth-compat/karma.conf.js b/packages/auth-compat/karma.conf.js index f3f14e8d1b1..6283ffbc3f1 100644 --- a/packages/auth-compat/karma.conf.js +++ b/packages/auth-compat/karma.conf.js @@ -30,18 +30,6 @@ module.exports = function (config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha'], - // undici is a fetch polyfill that test helpers call for Node tests, and browser tests should - // ignore its import to avoid compilation errors in those test helpers. - webpack: { - ...webpackBase, - resolve: { - ...webpackBase.resolve, - alias: { - 'undici': false - } - } - }, - client: Object.assign({}, karmaBase.client, getClientConfig()) }); diff --git a/packages/auth/karma.conf.js b/packages/auth/karma.conf.js index 1d28c329f55..f8dcd5b0341 100644 --- a/packages/auth/karma.conf.js +++ b/packages/auth/karma.conf.js @@ -27,17 +27,6 @@ module.exports = function (config) { // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter frameworks: ['mocha'], - // undici is a fetch polyfill that test helpers call for Node tests, and browser tests should - // ignore its import to avoid compilation errors in those test helpers. - webpack: { - ...webpackBase, - resolve: { - ...webpackBase.resolve, - alias: { - 'undici': false - } - } - }, client: Object.assign({}, karmaBase.client, getClientConfig(argv)) }); From 9c010b24445f3bd7c971f1b8a730d2715f699908 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 12 Sep 2024 21:56:54 -0400 Subject: [PATCH 13/34] Remove undici from firestore --- packages/firestore/package.json | 1 - packages/firestore/src/platform/browser_lite/connection.ts | 2 +- .../firestore/src/platform/browser_lite/fetch_connection.ts | 6 ++---- packages/firestore/src/platform/node_lite/connection.ts | 6 +----- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/packages/firestore/package.json b/packages/firestore/package.json index 1ba59e3a8dd..5c630f7837e 100644 --- a/packages/firestore/package.json +++ b/packages/firestore/package.json @@ -103,7 +103,6 @@ "@firebase/webchannel-wrapper": "1.0.1", "@grpc/grpc-js": "~1.9.0", "@grpc/proto-loader": "^0.7.8", - "undici": "6.19.7", "tslib": "^2.1.0" }, "peerDependencies": { diff --git a/packages/firestore/src/platform/browser_lite/connection.ts b/packages/firestore/src/platform/browser_lite/connection.ts index a6464245441..573f743a882 100644 --- a/packages/firestore/src/platform/browser_lite/connection.ts +++ b/packages/firestore/src/platform/browser_lite/connection.ts @@ -24,5 +24,5 @@ export { newConnectivityMonitor } from '../browser/connection'; /** Initializes the HTTP connection for the REST API. */ export function newConnection(databaseInfo: DatabaseInfo): Connection { - return new FetchConnection(databaseInfo, fetch.bind(null)); + return new FetchConnection(databaseInfo); } diff --git a/packages/firestore/src/platform/browser_lite/fetch_connection.ts b/packages/firestore/src/platform/browser_lite/fetch_connection.ts index cad3c372ad5..d1a980166da 100644 --- a/packages/firestore/src/platform/browser_lite/fetch_connection.ts +++ b/packages/firestore/src/platform/browser_lite/fetch_connection.ts @@ -30,11 +30,9 @@ import { StringMap } from '../../util/types'; export class FetchConnection extends RestConnection { /** * @param databaseInfo - The connection info. - * @param fetchImpl - `fetch` or a Polyfill that implements the fetch API. */ constructor( - databaseInfo: DatabaseInfo, - private readonly fetchImpl: typeof fetch + databaseInfo: DatabaseInfo ) { super(databaseInfo); } @@ -56,7 +54,7 @@ export class FetchConnection extends RestConnection { let response: Response; try { - response = await this.fetchImpl(url, { + response = await fetch(url, { method: 'POST', headers, body: requestJson diff --git a/packages/firestore/src/platform/node_lite/connection.ts b/packages/firestore/src/platform/node_lite/connection.ts index e85bb89bc97..fad9bf0b2ef 100644 --- a/packages/firestore/src/platform/node_lite/connection.ts +++ b/packages/firestore/src/platform/node_lite/connection.ts @@ -15,8 +15,6 @@ * limitations under the License. */ -import { fetch as undiciFetch } from 'undici'; - import { DatabaseInfo } from '../../core/database_info'; import { Connection } from '../../remote/connection'; import { FetchConnection } from '../browser_lite/fetch_connection'; @@ -25,8 +23,6 @@ export { newConnectivityMonitor } from '../browser/connection'; /** Initializes the HTTP connection for the REST API. */ export function newConnection(databaseInfo: DatabaseInfo): Connection { - // undici is meant to be API compatible with `fetch`, but its type doesn't - // match 100%. // eslint-disable-next-line @typescript-eslint/no-explicit-any - return new FetchConnection(databaseInfo, undiciFetch as any); + return new FetchConnection(databaseInfo); } From 69d789cf77aa19b725601fb635ca2635abbaed02 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 12 Sep 2024 22:21:07 -0400 Subject: [PATCH 14/34] Lint fix. --- .../src/platform/browser_lite/fetch_connection.ts | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/packages/firestore/src/platform/browser_lite/fetch_connection.ts b/packages/firestore/src/platform/browser_lite/fetch_connection.ts index d1a980166da..d11247c8019 100644 --- a/packages/firestore/src/platform/browser_lite/fetch_connection.ts +++ b/packages/firestore/src/platform/browser_lite/fetch_connection.ts @@ -16,7 +16,6 @@ */ import { Token } from '../../api/credentials'; -import { DatabaseInfo } from '../../core/database_info'; import { Stream } from '../../remote/connection'; import { RestConnection } from '../../remote/rest_connection'; import { mapCodeFromHttpStatus } from '../../remote/rpc_error'; @@ -28,15 +27,6 @@ import { StringMap } from '../../util/types'; * (e.g. `fetch` or a polyfill). */ export class FetchConnection extends RestConnection { - /** - * @param databaseInfo - The connection info. - */ - constructor( - databaseInfo: DatabaseInfo - ) { - super(databaseInfo); - } - openStream( rpcName: string, token: Token | null From c8c64e7dbb88463a6bb09f6fece28dacd96069ad Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 13 Sep 2024 09:13:45 -0400 Subject: [PATCH 15/34] Remove fetch from functions --- packages/functions/karma.conf.js | 13 +------------ packages/functions/package.json | 1 - packages/functions/src/index.node.ts | 3 +-- packages/functions/src/index.ts | 2 +- packages/functions/src/service.ts | 10 ++++------ packages/functions/test/utils.ts | 6 +----- 6 files changed, 8 insertions(+), 27 deletions(-) diff --git a/packages/functions/karma.conf.js b/packages/functions/karma.conf.js index 3dc9b7d572c..db9bf05bfe0 100644 --- a/packages/functions/karma.conf.js +++ b/packages/functions/karma.conf.js @@ -26,18 +26,7 @@ module.exports = function (config) { files, // frameworks to use // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ['mocha'], - // undici is a fetch polyfill that test helpers call for Node tests, and browser tests should - // ignore its import to avoid compilation errors in those test helpers. - webpack: { - ...webpackBase, - resolve: { - ...webpackBase.resolve, - alias: { - 'undici': false - } - } - } + frameworks: ['mocha'] }); config.set(karmaConfig); diff --git a/packages/functions/package.json b/packages/functions/package.json index 3ede8a4c3f9..5be9917b301 100644 --- a/packages/functions/package.json +++ b/packages/functions/package.json @@ -72,7 +72,6 @@ "@firebase/auth-interop-types": "0.2.3", "@firebase/app-check-interop-types": "0.3.2", "@firebase/util": "1.9.7", - "undici": "6.19.7", "tslib": "^2.1.0" }, "nyc": { diff --git a/packages/functions/src/index.node.ts b/packages/functions/src/index.node.ts index 6fb63173957..5e990cd8611 100644 --- a/packages/functions/src/index.node.ts +++ b/packages/functions/src/index.node.ts @@ -15,9 +15,8 @@ * limitations under the License. */ import { registerFunctions } from './config'; -import { fetch as undiciFetch } from 'undici'; export * from './api'; // eslint-disable-next-line @typescript-eslint/no-explicit-any -registerFunctions(undiciFetch as any, 'node'); +registerFunctions('node'); diff --git a/packages/functions/src/index.ts b/packages/functions/src/index.ts index 7318b3e64b7..6d404cc8245 100644 --- a/packages/functions/src/index.ts +++ b/packages/functions/src/index.ts @@ -25,4 +25,4 @@ import { registerFunctions } from './config'; export * from './api'; export * from './public-types'; -registerFunctions(fetch.bind(self)); +registerFunctions(); diff --git a/packages/functions/src/service.ts b/packages/functions/src/service.ts index c5fe7fa8a85..986dcbc735d 100644 --- a/packages/functions/src/service.ts +++ b/packages/functions/src/service.ts @@ -104,8 +104,7 @@ export class FunctionsService implements _FirebaseService { authProvider: Provider, messagingProvider: Provider, appCheckProvider: Provider, - regionOrCustomDomain: string = DEFAULT_REGION, - readonly fetchImpl: typeof fetch + regionOrCustomDomain: string = DEFAULT_REGION ) { this.contextProvider = new ContextProvider( authProvider, @@ -212,14 +211,13 @@ export function httpsCallableFromURL( async function postJSON( url: string, body: unknown, - headers: { [key: string]: string }, - fetchImpl: typeof fetch + headers: { [key: string]: string } ): Promise { headers['Content-Type'] = 'application/json'; let response: Response; try { - response = await fetchImpl(url, { + response = await fetch(url, { method: 'POST', body: JSON.stringify(body), headers @@ -296,7 +294,7 @@ async function callAtURL( const failAfterHandle = failAfter(timeout); const response = await Promise.race([ - postJSON(url, body, headers, functionsInstance.fetchImpl), + postJSON(url, body, headers), failAfterHandle.promise, functionsInstance.cancelAllRequests ]); diff --git a/packages/functions/test/utils.ts b/packages/functions/test/utils.ts index 0eb0b678c19..bcf0286b49d 100644 --- a/packages/functions/test/utils.ts +++ b/packages/functions/test/utils.ts @@ -21,7 +21,6 @@ import { FirebaseAuthInternalName } from '@firebase/auth-interop-types'; import { AppCheckInternalComponentName } from '@firebase/app-check-interop-types'; import { FunctionsService } from '../src/service'; import { connectFunctionsEmulator } from '../src/api'; -import { fetch as undiciFetch } from 'undici'; import { MessagingInternalComponentName } from '../../../packages/messaging-interop-types'; export function makeFakeApp(options: FirebaseOptions = {}): FirebaseApp { @@ -58,15 +57,12 @@ export function createTestService( new ComponentContainer('test') ) ): FunctionsService { - const fetchImpl: typeof fetch = - typeof window !== 'undefined' ? fetch.bind(window) : (undiciFetch as any); const functions = new FunctionsService( app, authProvider, messagingProvider, appCheckProvider, - region, - fetchImpl + region ); const useEmulator = !!process.env.FIREBASE_FUNCTIONS_EMULATOR_ORIGIN; if (useEmulator) { From b16903ba66aa3fdf2e96b32ac4245cb390e5f56f Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 13 Sep 2024 09:51:38 -0400 Subject: [PATCH 16/34] fix build --- packages/functions/src/index.node.ts | 2 +- packages/functions/src/index.ts | 2 +- packages/functions/src/service.ts | 10 ++++++---- packages/functions/test/utils.ts | 3 ++- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/functions/src/index.node.ts b/packages/functions/src/index.node.ts index 5e990cd8611..287451355b6 100644 --- a/packages/functions/src/index.node.ts +++ b/packages/functions/src/index.node.ts @@ -19,4 +19,4 @@ import { registerFunctions } from './config'; export * from './api'; // eslint-disable-next-line @typescript-eslint/no-explicit-any -registerFunctions('node'); +registerFunctions(fetch, 'node'); diff --git a/packages/functions/src/index.ts b/packages/functions/src/index.ts index 6d404cc8245..7318b3e64b7 100644 --- a/packages/functions/src/index.ts +++ b/packages/functions/src/index.ts @@ -25,4 +25,4 @@ import { registerFunctions } from './config'; export * from './api'; export * from './public-types'; -registerFunctions(); +registerFunctions(fetch.bind(self)); diff --git a/packages/functions/src/service.ts b/packages/functions/src/service.ts index 986dcbc735d..c5fe7fa8a85 100644 --- a/packages/functions/src/service.ts +++ b/packages/functions/src/service.ts @@ -104,7 +104,8 @@ export class FunctionsService implements _FirebaseService { authProvider: Provider, messagingProvider: Provider, appCheckProvider: Provider, - regionOrCustomDomain: string = DEFAULT_REGION + regionOrCustomDomain: string = DEFAULT_REGION, + readonly fetchImpl: typeof fetch ) { this.contextProvider = new ContextProvider( authProvider, @@ -211,13 +212,14 @@ export function httpsCallableFromURL( async function postJSON( url: string, body: unknown, - headers: { [key: string]: string } + headers: { [key: string]: string }, + fetchImpl: typeof fetch ): Promise { headers['Content-Type'] = 'application/json'; let response: Response; try { - response = await fetch(url, { + response = await fetchImpl(url, { method: 'POST', body: JSON.stringify(body), headers @@ -294,7 +296,7 @@ async function callAtURL( const failAfterHandle = failAfter(timeout); const response = await Promise.race([ - postJSON(url, body, headers), + postJSON(url, body, headers, functionsInstance.fetchImpl), failAfterHandle.promise, functionsInstance.cancelAllRequests ]); diff --git a/packages/functions/test/utils.ts b/packages/functions/test/utils.ts index bcf0286b49d..0f9a5ff0562 100644 --- a/packages/functions/test/utils.ts +++ b/packages/functions/test/utils.ts @@ -62,7 +62,8 @@ export function createTestService( authProvider, messagingProvider, appCheckProvider, - region + region, + fetch ); const useEmulator = !!process.env.FIREBASE_FUNCTIONS_EMULATOR_ORIGIN; if (useEmulator) { From 0c05f708fdea0846a09f5c4b518b54e640037da2 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 13 Sep 2024 10:05:01 -0400 Subject: [PATCH 17/34] Fixed build? --- packages/functions/src/config.ts | 4 +--- packages/functions/src/index.node.ts | 2 +- packages/functions/src/index.ts | 2 +- packages/functions/src/service.ts | 10 ++++------ packages/functions/test/utils.ts | 3 +-- 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/functions/src/config.ts b/packages/functions/src/config.ts index 6c4dac26e6a..cb3fdc5183b 100644 --- a/packages/functions/src/config.ts +++ b/packages/functions/src/config.ts @@ -36,7 +36,6 @@ const MESSAGING_INTERNAL_NAME: MessagingInternalComponentName = 'messaging-internal'; export function registerFunctions( - fetchImpl: typeof fetch, variant?: string ): void { const factory: InstanceFactory<'functions'> = ( @@ -55,8 +54,7 @@ export function registerFunctions( authProvider, messagingProvider, appCheckProvider, - regionOrCustomDomain, - fetchImpl + regionOrCustomDomain ); }; diff --git a/packages/functions/src/index.node.ts b/packages/functions/src/index.node.ts index 287451355b6..5e990cd8611 100644 --- a/packages/functions/src/index.node.ts +++ b/packages/functions/src/index.node.ts @@ -19,4 +19,4 @@ import { registerFunctions } from './config'; export * from './api'; // eslint-disable-next-line @typescript-eslint/no-explicit-any -registerFunctions(fetch, 'node'); +registerFunctions('node'); diff --git a/packages/functions/src/index.ts b/packages/functions/src/index.ts index 7318b3e64b7..6d404cc8245 100644 --- a/packages/functions/src/index.ts +++ b/packages/functions/src/index.ts @@ -25,4 +25,4 @@ import { registerFunctions } from './config'; export * from './api'; export * from './public-types'; -registerFunctions(fetch.bind(self)); +registerFunctions(); diff --git a/packages/functions/src/service.ts b/packages/functions/src/service.ts index c5fe7fa8a85..986dcbc735d 100644 --- a/packages/functions/src/service.ts +++ b/packages/functions/src/service.ts @@ -104,8 +104,7 @@ export class FunctionsService implements _FirebaseService { authProvider: Provider, messagingProvider: Provider, appCheckProvider: Provider, - regionOrCustomDomain: string = DEFAULT_REGION, - readonly fetchImpl: typeof fetch + regionOrCustomDomain: string = DEFAULT_REGION ) { this.contextProvider = new ContextProvider( authProvider, @@ -212,14 +211,13 @@ export function httpsCallableFromURL( async function postJSON( url: string, body: unknown, - headers: { [key: string]: string }, - fetchImpl: typeof fetch + headers: { [key: string]: string } ): Promise { headers['Content-Type'] = 'application/json'; let response: Response; try { - response = await fetchImpl(url, { + response = await fetch(url, { method: 'POST', body: JSON.stringify(body), headers @@ -296,7 +294,7 @@ async function callAtURL( const failAfterHandle = failAfter(timeout); const response = await Promise.race([ - postJSON(url, body, headers, functionsInstance.fetchImpl), + postJSON(url, body, headers), failAfterHandle.promise, functionsInstance.cancelAllRequests ]); diff --git a/packages/functions/test/utils.ts b/packages/functions/test/utils.ts index 0f9a5ff0562..bcf0286b49d 100644 --- a/packages/functions/test/utils.ts +++ b/packages/functions/test/utils.ts @@ -62,8 +62,7 @@ export function createTestService( authProvider, messagingProvider, appCheckProvider, - region, - fetch + region ); const useEmulator = !!process.env.FIREBASE_FUNCTIONS_EMULATOR_ORIGIN; if (useEmulator) { From 5077ae30846f259ad7075c27cc52cfe6335e0c95 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 13 Sep 2024 10:11:06 -0400 Subject: [PATCH 18/34] format --- packages/functions/src/config.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/functions/src/config.ts b/packages/functions/src/config.ts index cb3fdc5183b..656158da10d 100644 --- a/packages/functions/src/config.ts +++ b/packages/functions/src/config.ts @@ -35,9 +35,7 @@ const APP_CHECK_INTERNAL_NAME: AppCheckInternalComponentName = const MESSAGING_INTERNAL_NAME: MessagingInternalComponentName = 'messaging-internal'; -export function registerFunctions( - variant?: string -): void { +export function registerFunctions(variant?: string): void { const factory: InstanceFactory<'functions'> = ( container: ComponentContainer, { instanceIdentifier: regionOrCustomDomain } From 7a6691bcdb9b6b94e2313b8068de0e61af6f5a07 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 13 Sep 2024 11:12:42 -0400 Subject: [PATCH 19/34] Remove undici from storage --- packages/storage/package.json | 1 - packages/storage/src/platform/node/connection.ts | 6 ++---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/storage/package.json b/packages/storage/package.json index 94453f9fce8..c588756199f 100644 --- a/packages/storage/package.json +++ b/packages/storage/package.json @@ -50,7 +50,6 @@ "dependencies": { "@firebase/util": "1.9.7", "@firebase/component": "0.6.8", - "undici": "6.19.7", "tslib": "^2.1.0" }, "peerDependencies": { diff --git a/packages/storage/src/platform/node/connection.ts b/packages/storage/src/platform/node/connection.ts index d7141e6ef68..78aa0f1dd7a 100644 --- a/packages/storage/src/platform/node/connection.ts +++ b/packages/storage/src/platform/node/connection.ts @@ -21,7 +21,6 @@ import { ErrorCode } from '../../implementation/connection'; import { internalError } from '../../implementation/error'; -import { fetch as undiciFetch, Headers as undiciHeaders } from 'undici'; /** An override for the text-based Connection. Used in tests. */ let textFactoryOverride: (() => Connection) | null = null; @@ -39,9 +38,8 @@ abstract class FetchConnection protected statusCode_: number | undefined; protected body_: ArrayBuffer | undefined; protected errorText_ = ''; - protected headers_: undiciHeaders | undefined; + protected headers_: Headers | undefined; protected sent_: boolean = false; - protected fetch_ = undiciFetch; constructor() { this.errorCode_ = ErrorCode.NO_ERROR; @@ -59,7 +57,7 @@ abstract class FetchConnection this.sent_ = true; try { - const response = await this.fetch_(url, { + const response = await fetch(url, { method, headers: headers || {}, body: body as NodeJS.ArrayBufferView | string From 033c4dc5529ae4ae6d282acecc6e4e15d3ad1904 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 13 Sep 2024 11:12:54 -0400 Subject: [PATCH 20/34] Remove undici from changelog generator --- package.json | 1 - repo-scripts/changelog-generator/package.json | 3 +-- yarn.lock | 5 ----- 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/package.json b/package.json index 18ddbe42bff..41d92b74fb6 100644 --- a/package.json +++ b/package.json @@ -156,7 +156,6 @@ "tslint": "6.1.3", "typedoc": "0.16.11", "typescript": "4.7.4", - "undici": "6.19.7", "watch": "1.0.2", "webpack": "5.76.0", "yargs": "17.7.2" diff --git a/repo-scripts/changelog-generator/package.json b/repo-scripts/changelog-generator/package.json index 5d791be54bf..09313c27ed6 100644 --- a/repo-scripts/changelog-generator/package.json +++ b/repo-scripts/changelog-generator/package.json @@ -19,8 +19,7 @@ "dependencies": { "@changesets/types": "3.3.0", "@changesets/get-github-info": "0.5.2", - "@types/node": "20.8.10", - "undici": "6.19.7" + "@types/node": "20.8.10" }, "license": "Apache-2.0", "devDependencies": { diff --git a/yarn.lock b/yarn.lock index f80f8bbefef..f3fc015f9ec 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17371,11 +17371,6 @@ undici-types@~5.26.4: resolved "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -undici@6.19.7: - version "6.19.7" - resolved "https://registry.npmjs.org/undici/-/undici-6.19.7.tgz#7d4cf26dc689838aa8b6753a3c5c4288fc1e0216" - integrity sha512-HR3W/bMGPSr90i8AAp2C4DM3wChFdJPLrWYpIS++LxS8K+W535qftjt+4MyjNYHeWabMj1nvtmLIi7l++iq91A== - unicode-canonical-property-names-ecmascript@^2.0.0: version "2.0.0" resolved "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz" From 9aa1f75b926285271bfd5a257d6616dc6ab38995 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 13 Sep 2024 11:36:07 -0400 Subject: [PATCH 21/34] Fix storage test for node --- packages/storage/src/platform/node/connection.ts | 2 +- packages/storage/test/node/connection.test.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/storage/src/platform/node/connection.ts b/packages/storage/src/platform/node/connection.ts index 78aa0f1dd7a..c90f664c3b2 100644 --- a/packages/storage/src/platform/node/connection.ts +++ b/packages/storage/src/platform/node/connection.ts @@ -161,7 +161,7 @@ export class FetchStreamConnection extends FetchConnection< this.sent_ = true; try { - const response = await this.fetch_(url, { + const response = await fetch(url, { method, headers: headers || {}, body: body as NodeJS.ArrayBufferView | string diff --git a/packages/storage/test/node/connection.test.ts b/packages/storage/test/node/connection.test.ts index 32c499f0209..925d1f8f7dc 100644 --- a/packages/storage/test/node/connection.test.ts +++ b/packages/storage/test/node/connection.test.ts @@ -24,9 +24,9 @@ describe('Connections', () => { it('FetchConnection.send() should not reject on network errors', async () => { const connection = new FetchBytesConnection(); - // need the casting here because fetch_ is a private member - stub(connection as any, 'fetch_').rejects(); + const fetchStub = stub(globalThis, 'fetch').rejects(); await connection.send('testurl', 'GET'); expect(connection.getErrorCode()).to.equal(ErrorCode.NETWORK_ERROR); + fetchStub.restore(); }); }); From f35d2a00707ea748277bfaa7dd44ba217b8ec1aa Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Mon, 16 Sep 2024 14:51:07 -0400 Subject: [PATCH 22/34] Remove no longer required eslint-disable comments. --- packages/firestore/src/platform/node_lite/connection.ts | 1 - packages/functions/src/index.node.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/firestore/src/platform/node_lite/connection.ts b/packages/firestore/src/platform/node_lite/connection.ts index fad9bf0b2ef..7258661c184 100644 --- a/packages/firestore/src/platform/node_lite/connection.ts +++ b/packages/firestore/src/platform/node_lite/connection.ts @@ -23,6 +23,5 @@ export { newConnectivityMonitor } from '../browser/connection'; /** Initializes the HTTP connection for the REST API. */ export function newConnection(databaseInfo: DatabaseInfo): Connection { - // eslint-disable-next-line @typescript-eslint/no-explicit-any return new FetchConnection(databaseInfo); } diff --git a/packages/functions/src/index.node.ts b/packages/functions/src/index.node.ts index 5e990cd8611..fe3b450ff70 100644 --- a/packages/functions/src/index.node.ts +++ b/packages/functions/src/index.node.ts @@ -18,5 +18,4 @@ import { registerFunctions } from './config'; export * from './api'; -// eslint-disable-next-line @typescript-eslint/no-explicit-any registerFunctions('node'); From 1e25ff23d5e2af96178c75a6a438adf44759eec3 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Mon, 16 Sep 2024 14:55:51 -0400 Subject: [PATCH 23/34] Functions export public-types --- packages/functions/src/index.node.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/functions/src/index.node.ts b/packages/functions/src/index.node.ts index fe3b450ff70..6b1a2ee2939 100644 --- a/packages/functions/src/index.node.ts +++ b/packages/functions/src/index.node.ts @@ -17,5 +17,6 @@ import { registerFunctions } from './config'; export * from './api'; +export * from './public-types'; registerFunctions('node'); From 7acb14e1512fe33a4c1a7d42fda05f845707b06c Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 19 Sep 2024 10:50:50 -0400 Subject: [PATCH 24/34] Auth - remove superfluous casting. --- packages/auth/src/platform_node/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/auth/src/platform_node/index.ts b/packages/auth/src/platform_node/index.ts index d0c7425a350..387cb3905de 100644 --- a/packages/auth/src/platform_node/index.ts +++ b/packages/auth/src/platform_node/index.ts @@ -31,9 +31,9 @@ import { getDefaultEmulatorHost } from '@firebase/util'; // Initialize the fetch polyfill, the types are slightly off so just cast and hope for the best FetchProvider.initialize( - fetch as unknown as typeof fetch, - Headers as unknown as typeof Headers, - Response as unknown as typeof Response + fetch, + Headers, + Response ); // First, we set up the various platform-specific features for Node (register From 498bc7b65fcd1a45cfe02bec8569abb93754050b Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Thu, 19 Sep 2024 11:10:43 -0400 Subject: [PATCH 25/34] Fix hanging promise in emulator download code --- packages/auth/src/platform_node/index.ts | 6 +----- .../emulator-testing/emulators/emulator.ts | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/packages/auth/src/platform_node/index.ts b/packages/auth/src/platform_node/index.ts index 387cb3905de..67618b5b773 100644 --- a/packages/auth/src/platform_node/index.ts +++ b/packages/auth/src/platform_node/index.ts @@ -30,11 +30,7 @@ import { FetchProvider } from '../core/util/fetch_provider'; import { getDefaultEmulatorHost } from '@firebase/util'; // Initialize the fetch polyfill, the types are slightly off so just cast and hope for the best -FetchProvider.initialize( - fetch, - Headers, - Response -); +FetchProvider.initialize(fetch, Headers, Response); // First, we set up the various platform-specific features for Node (register // the version and declare the Node getAuth function) diff --git a/scripts/emulator-testing/emulators/emulator.ts b/scripts/emulator-testing/emulators/emulator.ts index fa6059706a6..ba69e049ad6 100644 --- a/scripts/emulator-testing/emulators/emulator.ts +++ b/scripts/emulator-testing/emulators/emulator.ts @@ -62,19 +62,20 @@ export abstract class Emulator { (downloadComplete, downloadFailed) => { fetch(this.binaryUrl) .then(resp => { - if (resp.status !== 200) { + if (resp.status !== 200 || resp.body === null) { console.log('Download of emulator failed: ', resp.statusText); downloadFailed(); + } else { + const reader = resp.body.getReader(); + reader.read().then(function readChunk({ done, value }): any { + if (done) { + downloadComplete(); + } else { + writer.write(value); + return reader.read().then(readChunk); + } + }); } - const reader = resp.body?.getReader(); - reader?.read().then(function readChunk({ done, value }): any { - if (done) { - downloadComplete(); - } else { - writer.write(value); - return reader.read().then(readChunk); - } - }); }) .catch(e => { console.log(`Download of emulator failed: ${e}`); From 10a6149b5a09d04ffeee8470b6414b7bba97328b Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 20 Sep 2024 09:27:08 -0400 Subject: [PATCH 26/34] Remove fetch casting in auth-compat --- packages/auth-compat/index.node.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/auth-compat/index.node.ts b/packages/auth-compat/index.node.ts index 7ab2677c060..1513148bea9 100644 --- a/packages/auth-compat/index.node.ts +++ b/packages/auth-compat/index.node.ts @@ -25,8 +25,4 @@ export * from './index'; import { FetchProvider } from '@firebase/auth/internal'; import './index'; -FetchProvider.initialize( - fetch as unknown as typeof fetch, - Headers as unknown as typeof Headers, - Response as unknown as typeof Response -); +FetchProvider.initialize(fetch, Headers, Response); From 10e089e6f267c3845feefc5bd12502a51b73fa2d Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 20 Sep 2024 10:22:14 -0400 Subject: [PATCH 27/34] Changeset --- .changeset/plenty-beers-decide.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .changeset/plenty-beers-decide.md diff --git a/.changeset/plenty-beers-decide.md b/.changeset/plenty-beers-decide.md new file mode 100644 index 00000000000..8f57c0d677b --- /dev/null +++ b/.changeset/plenty-beers-decide.md @@ -0,0 +1,22 @@ +--- +'@firebase/rules-unit-testing': patch +'@firebase/app-check-compat': patch +'@firebase/firestore-compat': patch +'@firebase/functions-compat': patch +'@firebase/database-compat': patch +'@firebase/storage-compat': patch +'@firebase/auth-compat': patch +'@firebase/app-compat': patch +'@firebase/app-check': patch +'@firebase/component': patch +'@firebase/firestore': patch +'@firebase/functions': patch +'@firebase/database': patch +'@firebase/storage': patch +'@firebase/logger': patch +'@firebase/auth': patch +'@firebase/util': patch +'@firebase/app': patch +--- + +Removed dependency on undici and node-fetch in our node bundles, replacing them with the native fetch implementation. From d517b14927445a13a3ea89aeb760d42b6d0f20f6 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 20 Sep 2024 10:28:02 -0400 Subject: [PATCH 28/34] Changeset 2 --- .changeset/plenty-beers-decide.md | 9 --------- 1 file changed, 9 deletions(-) diff --git a/.changeset/plenty-beers-decide.md b/.changeset/plenty-beers-decide.md index 8f57c0d677b..87bc58c3589 100644 --- a/.changeset/plenty-beers-decide.md +++ b/.changeset/plenty-beers-decide.md @@ -1,22 +1,13 @@ --- '@firebase/rules-unit-testing': patch -'@firebase/app-check-compat': patch '@firebase/firestore-compat': patch '@firebase/functions-compat': patch -'@firebase/database-compat': patch '@firebase/storage-compat': patch '@firebase/auth-compat': patch -'@firebase/app-compat': patch -'@firebase/app-check': patch -'@firebase/component': patch '@firebase/firestore': patch '@firebase/functions': patch -'@firebase/database': patch '@firebase/storage': patch -'@firebase/logger': patch '@firebase/auth': patch -'@firebase/util': patch -'@firebase/app': patch --- Removed dependency on undici and node-fetch in our node bundles, replacing them with the native fetch implementation. From 399efc0472aea5e48f75fdc360a2fbd36f9ddd17 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 20 Sep 2024 11:44:50 -0400 Subject: [PATCH 29/34] Remove functions node bundle --- packages/functions/package.json | 6 +++--- packages/functions/rollup.config.js | 26 +------------------------- packages/functions/src/index.node.ts | 22 ---------------------- 3 files changed, 4 insertions(+), 50 deletions(-) delete mode 100644 packages/functions/src/index.node.ts diff --git a/packages/functions/package.json b/packages/functions/package.json index 5be9917b301..31d9b9df126 100644 --- a/packages/functions/package.json +++ b/packages/functions/package.json @@ -3,7 +3,7 @@ "version": "0.11.6", "description": "", "author": "Firebase (https://firebase.google.com/)", - "main": "dist/index.node.cjs.js", + "main": "dist/index.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", "esm5": "dist/index.esm.js", @@ -11,8 +11,8 @@ ".": { "types": "./dist/functions-public.d.ts", "node": { - "import": "./dist/esm-node/index.node.esm.js", - "require": "./dist/index.node.cjs.js" + "import": "./dist/index.esm2017.js", + "require": "./dist/index.cjs.js" }, "esm5": "./dist/index.esm.js", "browser": { diff --git a/packages/functions/rollup.config.js b/packages/functions/rollup.config.js index bb5506ea9b5..4bc7f73d869 100644 --- a/packages/functions/rollup.config.js +++ b/packages/functions/rollup.config.js @@ -84,28 +84,4 @@ const browserBuilds = [ } ]; -const nodeBuilds = [ - { - input: 'src/index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es5BuildPlugins, - replace(generateBuildTargetReplaceConfig('cjs', 5)) - ] - }, - { - input: 'src/index.node.ts', - output: [ - { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } - ], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)), - plugins: [ - ...es2017BuildPlugins, - replace(generateBuildTargetReplaceConfig('esm', 2017)), - emitModulePackageFile() - ] - } -]; - -export default [...browserBuilds, ...nodeBuilds]; +export default [...browserBuilds]; diff --git a/packages/functions/src/index.node.ts b/packages/functions/src/index.node.ts deleted file mode 100644 index 6b1a2ee2939..00000000000 --- a/packages/functions/src/index.node.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * @license - * Copyright 2017 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { registerFunctions } from './config'; - -export * from './api'; -export * from './public-types'; - -registerFunctions('node'); From 8bb819b80f8db40d92c1dc5c8b45ebc98333e454 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 20 Sep 2024 11:47:51 -0400 Subject: [PATCH 30/34] Changeset --- .changeset/slimy-cups-promise.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/slimy-cups-promise.md diff --git a/.changeset/slimy-cups-promise.md b/.changeset/slimy-cups-promise.md new file mode 100644 index 00000000000..9456c0d5b04 --- /dev/null +++ b/.changeset/slimy-cups-promise.md @@ -0,0 +1,6 @@ +--- +'@firebase/functions-compat': patch +'@firebase/functions': patch +--- + +Remove node bundle from the functions SDK as the node-specific fetch code has been removed in favor of using native fetch throughout the SDK. From 49f0618cc615053b2f27259c359da9c022dbd433 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 20 Sep 2024 13:02:54 -0400 Subject: [PATCH 31/34] Change test:node target file --- packages/functions/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/functions/package.json b/packages/functions/package.json index 31d9b9df126..4d7162236d8 100644 --- a/packages/functions/package.json +++ b/packages/functions/package.json @@ -38,7 +38,7 @@ "test:all": "run-p --npm-path npm test:browser test:node", "test:browser": "karma start --single-run", "test:browser:debug": "karma start --browsers=Chrome --auto-watch", - "test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'src/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js", + "test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'src/{,!(browser)/**/}*.test.ts' --file src/index.ts --config ../../config/mocharc.node.js", "test:emulator": "env FIREBASE_FUNCTIONS_EMULATOR_ORIGIN=http://localhost:5005 run-p --npm-path npm test:node", "trusted-type-check": "tsec -p tsconfig.json --noEmit", "api-report": "api-extractor run --local --verbose", From 3f14414aff0c0c939f68c4566f6a5596a88364fa Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 20 Sep 2024 13:29:00 -0400 Subject: [PATCH 32/34] Update functions-compat --- packages/functions-compat/package.json | 6 +++--- packages/functions-compat/rollup.config.js | 19 +------------------ 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/packages/functions-compat/package.json b/packages/functions-compat/package.json index 5ff623872f8..e34c5c03be0 100644 --- a/packages/functions-compat/package.json +++ b/packages/functions-compat/package.json @@ -3,7 +3,7 @@ "version": "0.3.12", "description": "", "author": "Firebase (https://firebase.google.com/)", - "main": "dist/index.node.cjs.js", + "main": "dist/index.cjs.js", "browser": "dist/index.esm2017.js", "module": "dist/index.esm2017.js", "esm5": "dist/index.esm5.js", @@ -11,8 +11,8 @@ ".": { "types": "./dist/src/index.d.ts", "node": { - "import": "./dist/node-esm/index.node.esm.js", - "require": "./dist/index.node.cjs.js" + "require": "./dist/index.cjs.js", + "import": "./dist/index.esm2017.js" }, "esm5": "./dist/index.esm5.js", "browser": { diff --git a/packages/functions-compat/rollup.config.js b/packages/functions-compat/rollup.config.js index 949aeebd513..53aad50475a 100644 --- a/packages/functions-compat/rollup.config.js +++ b/packages/functions-compat/rollup.config.js @@ -73,21 +73,4 @@ const browserBuilds = [ } ]; -const nodeBuilds = [ - { - input: 'src/index.node.ts', - output: [{ file: pkg.main, format: 'cjs', sourcemap: true }], - plugins: es5BuildPlugins, - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - }, - { - input: 'src/index.node.ts', - output: [ - { file: pkg.exports['.'].node.import, format: 'es', sourcemap: true } - ], - plugins: [...es2017BuildPlugins, emitModulePackageFile()], - external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`)) - } -]; - -export default [...browserBuilds, ...nodeBuilds]; +export default [...browserBuilds]; From c055cfe67a40e801702776bcd0283025717f40ad Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Fri, 20 Sep 2024 16:38:40 -0400 Subject: [PATCH 33/34] remove --file src/index.node.ts from functions-compat --- packages/functions-compat/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/functions-compat/package.json b/packages/functions-compat/package.json index e34c5c03be0..feefbf20770 100644 --- a/packages/functions-compat/package.json +++ b/packages/functions-compat/package.json @@ -57,7 +57,7 @@ "test:all": "run-p --npm-path npm test:browser test:node", "test:browser": "karma start --single-run", "test:browser:debug": "karma start --browsers=Chrome --auto-watch", - "test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'src/{,!(browser)/**/}*.test.ts' --file src/index.node.ts --config ../../config/mocharc.node.js", + "test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha 'src/{,!(browser)/**/}*.test.ts' --config ../../config/mocharc.node.js", "test:emulator": "env FIREBASE_FUNCTIONS_HOST=http://localhost FIREBASE_FUNCTIONS_PORT=5005 run-p --npm-path npm test:node", "trusted-type-check": "tsec -p tsconfig.json --noEmit", "add-compat-overloads": "ts-node-script ../../scripts/build/create-overloads.ts -i ../functions/dist/functions-public.d.ts -o dist/src/index.d.ts -a -r Functions:types.FirebaseFunctions -r FirebaseApp:FirebaseAppCompat --moduleToEnhance @firebase/functions" From 9da8f0605a2e3ea291744a6dfde3bdb499271a16 Mon Sep 17 00:00:00 2001 From: DellaBitta Date: Sun, 22 Sep 2024 08:34:36 -0400 Subject: [PATCH 34/34] Delete index.node.ts --- packages/functions-compat/src/index.node.ts | 23 --------------------- 1 file changed, 23 deletions(-) delete mode 100644 packages/functions-compat/src/index.node.ts diff --git a/packages/functions-compat/src/index.node.ts b/packages/functions-compat/src/index.node.ts deleted file mode 100644 index e7b3c108ac4..00000000000 --- a/packages/functions-compat/src/index.node.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * @license - * Copyright 2020 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import firebase from '@firebase/app-compat'; -import { name, version } from '../package.json'; -import { registerFunctions } from './register'; - -registerFunctions(); -firebase.registerVersion(name, version, 'node');