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

Remove AbortController polyfill as it is no longer needed and use native fetch where possible #8162

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
298 changes: 200 additions & 98 deletions npm-shrinkwrap.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@
"@electric-sql/pglite": "^0.2.16",
"@google-cloud/cloud-sql-connector": "^1.3.3",
"@google-cloud/pubsub": "^4.5.0",
"abort-controller": "^3.0.0",
"ajv": "^8.17.1",
"ajv-formats": "3.0.1",
"archiver": "^7.0.0",
Expand Down Expand Up @@ -142,7 +141,7 @@
"mime": "^2.5.2",
"minimatch": "^3.0.4",
"morgan": "^1.10.0",
"node-fetch": "^2.6.7",
"node-fetch": "^2.7.0",
"open": "^6.3.0",
"ora": "^5.4.1",
"p-limit": "^3.0.1",
Expand Down Expand Up @@ -198,7 +197,7 @@
"@types/mock-fs": "4.13.4",
"@types/multer": "^1.4.3",
"@types/node": "^18.19.1",
"@types/node-fetch": "^2.5.12",
"@types/node-fetch": "^2.6.12",
"@types/pg": "^8.11.2",
"@types/progress": "^2.0.3",
"@types/react": "^18.2.58",
Expand Down
1 change: 0 additions & 1 deletion src/apiv2.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createServer, Server } from "http";
import { expect } from "chai";
import * as nock from "nock";
import AbortController from "abort-controller";
const proxySetup = require("proxy");

import { Client } from "./apiv2";
Expand Down
7 changes: 2 additions & 5 deletions src/apiv2.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import { AbortSignal } from "abort-controller";
import { URL, URLSearchParams } from "url";
import { Readable } from "stream";
import { ProxyAgent } from "proxy-agent";
import * as retry from "retry";
import AbortController from "abort-controller";
import fetch, { HeadersInit, Response, RequestInit, Headers } from "node-fetch";
import util from "util";

import * as auth from "./auth";
import { FirebaseError } from "./error";
import { logger } from "./logger";
Expand Down Expand Up @@ -365,7 +362,7 @@ export class Client {
}

if (options.signal) {
fetchOptions.signal = options.signal;
fetchOptions.signal = options.signal as RequestInit["signal"];
}

let reqTimeout: NodeJS.Timeout | undefined;
Expand All @@ -374,7 +371,7 @@ export class Client {
reqTimeout = setTimeout(() => {
controller.abort();
}, options.timeout);
fetchOptions.signal = controller.signal;
fetchOptions.signal = controller.signal as RequestInit["signal"];
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is due to node-fetch AbortController types not being up-to-date with the runtime AbortController which supports more features

}

if (typeof options.body === "string" || isStream(options.body)) {
Expand Down
1 change: 0 additions & 1 deletion src/deploy/hosting/uploader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { size } from "lodash";
import AbortController from "abort-controller";
import * as clc from "colorette";
import * as crypto from "crypto";
import * as fs from "fs";
Expand Down
2 changes: 0 additions & 2 deletions src/emulator/auth/operations.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { URLSearchParams } from "url";
import { decode as decodeJwt, sign as signJwt, JwtHeader } from "jsonwebtoken";
import * as express from "express";
import fetch from "node-fetch";
import AbortController from "abort-controller";
import { ExegesisContext } from "exegesis-express";
import {
toUnixTimestamp,
Expand Down
1 change: 0 additions & 1 deletion src/emulator/taskQueue.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as _ from "lodash";
import * as sinon from "sinon";
import * as nodeFetch from "node-fetch";
import AbortController from "abort-controller";
import { expect } from "chai";
import { EmulatedTask, EmulatedTaskMetadata, Queue, TaskQueue, TaskStatus } from "./taskQueue";
import { RateLimits, RetryConfig, Task, TaskQueueConfig } from "./tasksEmulator";
Expand Down
4 changes: 1 addition & 3 deletions src/emulator/taskQueue.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import AbortController from "abort-controller";
import { EmulatorLogger } from "./emulatorLogger";
import { RetryConfig, Task, TaskQueueConfig } from "./tasksEmulator";
import { Emulators } from "./types";
import fetch from "node-fetch";

class Node<T> {
public data: T;
Expand Down Expand Up @@ -298,7 +296,7 @@ export class TaskQueue {
method: "POST",
headers: headers,
body: JSON.stringify(emulatedTask.task.httpRequest.body),
signal: signal,
signal,
});

const dispatchDeadline = emulatedTask.task.dispatchDeadline;
Expand Down
1 change: 0 additions & 1 deletion src/profiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as fs from "fs";
import * as ora from "ora";
import * as readline from "readline";
import * as tmp from "tmp";
import AbortController from "abort-controller";

import { Client } from "./apiv2";
import { realtimeOriginOrEmulatorOrCustomUrl } from "./database/api";
Expand Down