Skip to content
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
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@
"@google-cloud/pubsub": "^5.2.0",
"@inquirer/prompts": "^7.10.1",
"@modelcontextprotocol/sdk": "^1.24.0",
"abort-controller": "^3.0.0",
"ajv": "^8.17.1",
"ajv-formats": "3.0.1",
"archiver": "^7.0.0",
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, CLI_OAUTH_PROJECT_NUMBER } from "./apiv2";
Expand Down
18 changes: 3 additions & 15 deletions src/apiv2.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
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";
Comment thread
gameroman marked this conversation as resolved.
import fetch, { HeadersInit, Response, RequestInit, Headers } from "node-fetch";
import util from "util";

Expand Down Expand Up @@ -386,26 +384,16 @@ export class Client {
}

if (options.signal) {
const signal = options.signal as any;
signal.reason = "";
signal.throwIfAborted = () => {
throw new FirebaseError("Aborted");
};
fetchOptions.signal = signal;
fetchOptions.signal = options.signal;
}

let reqTimeout: NodeJS.Timeout | undefined;
if (options.timeout) {
const controller = new AbortController();
reqTimeout = setTimeout(() => {
controller.abort();
controller.abort(new FirebaseError("Aborted"));
}, options.timeout);
const signal = controller.signal as any;
signal.reason = "";
signal.throwIfAborted = () => {
throw new FirebaseError("Aborted");
};
fetchOptions.signal = signal;
fetchOptions.signal = controller.signal;
}

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
9 changes: 2 additions & 7 deletions src/emulator/auth/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,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";
Comment thread
gameroman marked this conversation as resolved.
import { ExegesisContext } from "exegesis-express";
import {
toUnixTimestamp,
Expand Down Expand Up @@ -3134,19 +3133,15 @@ async function fetchBlockingFunction(

const controller = new AbortController();
const timeout = setTimeout(() => {
controller.abort();
controller.abort(new FirebaseError("Aborted"));
}, timeoutMs);

let response: BlockingFunctionResponsePayload;
let ok: boolean;
let status: number;
let text: string;
try {
const signal = controller.signal as any;
signal.reason = "";
signal.throwIfAborted = () => {
throw new FirebaseError("Aborted");
};
const signal = controller.signal;
const res = await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
Expand Down
9 changes: 2 additions & 7 deletions src/emulator/taskQueue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import AbortController from "abort-controller";
Comment thread
gameroman marked this conversation as resolved.
import { EmulatorLogger } from "./emulatorLogger";
import { RetryConfig, Task, TaskQueueConfig } from "./tasksEmulator";
import { Emulators } from "./types";
Expand Down Expand Up @@ -294,11 +293,7 @@ export class TaskQueue {
headers["X-CloudTasks-TaskPreviousResponse"] = `${emulatedTask.metadata.previousResponse}`;
}
const controller = new AbortController();
const signal = controller.signal as any;
signal.reason = "";
signal.throwIfAborted = () => {
throw new FirebaseError("Aborted");
};
const signal = controller.signal;
const request = fetch(emulatedTask.task.httpRequest.url, {
method: "POST",
headers: headers,
Expand All @@ -313,7 +308,7 @@ export class TaskQueue {

const abortId = setTimeout(() => {
// TODO: Set X-CloudTasks-TaskRetryReason
controller.abort();
controller.abort(new FirebaseError("Aborted"));
}, dispatchDeadlineSeconds * 1000);

const response = await request;
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