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

Replace node-fetch dependency with undici #7705

Merged
merged 44 commits into from
Nov 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6f959f7
update node-fetch to 3.2.0
DellaBitta Oct 17, 2023
dca8b45
repo scripts build fixes
DellaBitta Oct 17, 2023
8bd20e7
upgrade to node fetch 3.3.2
DellaBitta Oct 17, 2023
3e19c06
attempt to template reponse as Object
DellaBitta Oct 17, 2023
b0b57d4
emulator list as any
DellaBitta Oct 18, 2023
170d8b8
convert changelog generator from type module to commonjs due to node-…
DellaBitta Oct 18, 2023
c7cb29a
URL to string
DellaBitta Oct 18, 2023
36030be
formatting
DellaBitta Oct 18, 2023
915d6d9
formatting2
DellaBitta Oct 18, 2023
87f7aee
yarn.lock file
DellaBitta Oct 18, 2023
1e5315d
functions -> node-fetch-cjs, rulesunittesting -> node-fetch
DellaBitta Oct 24, 2023
8a32b0d
auth, firestore, storage -> node-fetch-cjs
DellaBitta Oct 24, 2023
2de208f
node-fetch-cjs package.json
DellaBitta Oct 24, 2023
5943873
webpack config
DellaBitta Oct 25, 2023
61778a4
update to emulator_rest_helpers import of undici
DellaBitta Oct 26, 2023
0a2f3d2
update auth-compat
DellaBitta Oct 26, 2023
1b0a813
lint fixes
DellaBitta Oct 27, 2023
197de53
revert messaging integration test changes
DellaBitta Oct 27, 2023
c4411bc
yarn.lock push
DellaBitta Oct 27, 2023
187ff43
replaced node-fetch-cjs with undici
DellaBitta Oct 27, 2023
c50be9b
narrow scoped imports
DellaBitta Oct 27, 2023
e852caa
pushed undici-specific code to an else block within emulator_rest_hel…
DellaBitta Oct 29, 2023
a439ac9
format and functions changes
DellaBitta Oct 29, 2023
60dd788
firestore lint fix
DellaBitta Oct 29, 2023
a9f1f90
Changeset
DellaBitta Oct 29, 2023
4caec8d
Merge branch 'master' into ddb-upgrade-node-fetch
DellaBitta Oct 30, 2023
24d8c2a
Merge branch 'master' into ddb-upgrade-node-fetch
DellaBitta Nov 3, 2023
194ad81
Update changeset from patch to minor
DellaBitta Nov 5, 2023
4a48807
add comments to karma.conf.js files regarding why we're suppressing t…
DellaBitta Nov 5, 2023
1750136
mangle undici fetch imports as undiciFetch
DellaBitta Nov 5, 2023
8a29288
migrate node-fetch to undici in repo_scripts
DellaBitta Nov 5, 2023
2f8bfd8
removed errant , in repo-scripts package.json
DellaBitta Nov 5, 2023
140d686
revert undici upgrade of repo-scripts
DellaBitta Nov 6, 2023
02c4922
lint fix
DellaBitta Nov 6, 2023
272ea2a
generated new changeset with minor patch levels
DellaBitta Nov 6, 2023
632e2da
add firebase minor version entry to changeset file
DellaBitta Nov 6, 2023
083ebaa
add firebase minor version entry to changeset file
DellaBitta Nov 6, 2023
e93d827
Update to changeset conflict
DellaBitta Nov 6, 2023
395c420
migrate changelog-generator to undici
DellaBitta Nov 8, 2023
8ff801b
replace node-fetch in testing support for RUT, messaging and emulators
DellaBitta Nov 8, 2023
a95a38d
format and fetch rename fixes
DellaBitta Nov 8, 2023
3febc4c
revert undici changes in tests
DellaBitta Nov 8, 2023
b41fcde
Update remaining test targets to use undici (#7761)
DellaBitta Nov 10, 2023
fcb842c
revert changes from RUT to be implemented later
DellaBitta Nov 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
revert changes from RUT to be implemented later
  • Loading branch information
DellaBitta committed Nov 10, 2023
commit fcb842c8fc7a42f43ea2d5172c678b0c516967d0
4 changes: 2 additions & 2 deletions .changeset/real-dolls-type.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---
'@firebase/rules-unit-testing': minor
'@firebase/auth-compat': minor
'@firebase/firestore': minor
'@firebase/functions': minor
Expand All @@ -8,4 +7,5 @@
'firebase': minor
---

Replaced node-fetch v2.6.7 dependency with the latest version of undici (v5.26.5) in Node.js SDK builds.
Replaced node-fetch v2.6.7 dependency with the latest version of undici (v5.26.5) in Node.js SDK
builds for auth, firestore, functions and storage.
147,406 changes: 147,406 additions & 0 deletions .yarn/releases/yarn-1.22.11.cjs

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion packages/rules-unit-testing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"url": "https://github.com/firebase/firebase-js-sdk/issues"
},
"dependencies": {
"undici": "5.26.5",
"node-fetch": "2.6.7",
"@types/node-fetch": "2.6.4"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/rules-unit-testing/src/impl/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export async function discoverEmulators(

const emulators: DiscoveredEmulators = {};

const data = (await res.json()) as any;
const data = await res.json();

if (data.database) {
emulators.database = {
Expand Down
8 changes: 4 additions & 4 deletions packages/rules-unit-testing/src/impl/rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import { HostAndPort } from '../public_types';
import { makeUrl } from './url';
import { fetch as undiciFetch } from 'undici';
import fetch from 'node-fetch';

/**
* @private
Expand All @@ -29,7 +29,7 @@ export async function loadDatabaseRules(
): Promise<void> {
const url = makeUrl(hostAndPort, '/.settings/rules.json');
url.searchParams.append('ns', databaseName);
const resp = await undiciFetch(url, {
const resp = await fetch(url, {
method: 'PUT',
headers: { Authorization: 'Bearer owner' },
body: rules
Expand All @@ -48,7 +48,7 @@ export async function loadFirestoreRules(
projectId: string,
rules: string
): Promise<void> {
const resp = await undiciFetch(
const resp = await fetch(
makeUrl(hostAndPort, `/emulator/v1/projects/${projectId}:securityRules`),
{
method: 'PUT',
Expand All @@ -72,7 +72,7 @@ export async function loadStorageRules(
hostAndPort: HostAndPort,
rules: string
): Promise<void> {
const resp = await undiciFetch(makeUrl(hostAndPort, '/internal/setRules'), {
const resp = await fetch(makeUrl(hostAndPort, '/internal/setRules'), {
method: 'PUT',
headers: {
'Content-Type': 'application/json'
Expand Down
4 changes: 2 additions & 2 deletions packages/rules-unit-testing/src/impl/test_environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import { fetch as undiciFetch } from 'undici';
import fetch from 'node-fetch';
import firebase from 'firebase/compat/app';
import 'firebase/compat/firestore';
import 'firebase/compat/database';
Expand Down Expand Up @@ -106,7 +106,7 @@ export class RulesTestEnvironmentImpl implements RulesTestEnvironment {
this.checkNotDestroyed();
assertEmulatorRunning(this.emulators, 'firestore');

const resp = await undiciFetch(
const resp = await fetch(
makeUrl(
this.emulators.firestore,
`/emulator/v1/projects/${this.projectId}/databases/(default)/documents`
Expand Down
7 changes: 3 additions & 4 deletions packages/rules-unit-testing/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
} from './impl/discovery';
import { fixHostname, makeUrl } from './impl/url';
import { HostAndPort } from './public_types';
import { fetch as undiciFetch } from 'undici';
import fetch from 'node-fetch';

/**
* Run a setup function with background Cloud Functions triggers disabled. This can be used to
Expand Down Expand Up @@ -79,13 +79,12 @@ export async function withFunctionTriggersDisabled<TResult>(
hub.host = fixHostname(hub.host);
makeUrl(hub, '/functions/disableBackgroundTriggers');
// Disable background triggers
const disableRes = await undiciFetch(
const disableRes = await fetch(
makeUrl(hub, '/functions/disableBackgroundTriggers'),
{
method: 'PUT'
}
);

if (!disableRes.ok) {
throw new Error(
`HTTP Error ${disableRes.status} when disabling functions triggers, are you using firebase-tools 8.13.0 or higher?`
Expand All @@ -98,7 +97,7 @@ export async function withFunctionTriggersDisabled<TResult>(
result = await maybeFn();
} finally {
// Re-enable background triggers
const enableRes = await undiciFetch(
const enableRes = await fetch(
makeUrl(hub, '/functions/enableBackgroundTriggers'),
{
method: 'PUT'
Expand Down
4 changes: 2 additions & 2 deletions packages/rules-unit-testing/test/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ describe('assertFails()', () => {

describe('withFunctionTriggersDisabled()', () => {
it('disabling function triggers does not throw, returns value', async function () {
const fetchSpy = sinon.spy(require('undici'), 'fetch');
const fetchSpy = sinon.spy(require('node-fetch'), 'default');

const res = await withFunctionTriggersDisabled(() => {
return Promise.resolve(1234);
Expand All @@ -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('undici'), 'fetch');
const fetchSpy = sinon.spy(require('node-fetch'), 'default');

const res = withFunctionTriggersDisabled(() => {
throw new Error('I throw!');
Expand Down