Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
165 changes: 98 additions & 67 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
"@electric-sql/pglite": "^0.3.3",
"@electric-sql/pglite-tools": "^0.2.8",
"@google-cloud/cloud-sql-connector": "^1.3.3",
"@google-cloud/pubsub": "^4.5.0",
"@google-cloud/pubsub": "^4.11.0",
"@inquirer/prompts": "^7.4.0",
"@modelcontextprotocol/sdk": "^1.10.2",
"abort-controller": "^3.0.0",
Expand Down Expand Up @@ -209,7 +209,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.13",
"@types/pg": "^8.11.2",
"@types/progress": "^2.0.3",
"@types/react": "^18.2.58",
Expand Down
16 changes: 14 additions & 2 deletions src/apiv2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

// Using import would require resolveJsonModule, which seems to break the
// build/output format.
const pkg = require("../package.json");

Check warning on line 18 in src/apiv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Require statement not part of import statement

Check warning on line 18 in src/apiv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
const CLI_VERSION: string = pkg.version;

Check warning on line 19 in src/apiv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .version on an `any` value

Check warning on line 19 in src/apiv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

export const STANDARD_HEADERS: Record<string, string> = {
Connection: "keep-alive",
Expand Down Expand Up @@ -124,7 +124,7 @@

/**
* Gets a singleton access token
* @returns An access token

Check warning on line 127 in src/apiv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid JSDoc tag (preference). Replace "returns" JSDoc tag with "return"
*/
export async function getAccessToken(): Promise<string> {
const valid = auth.haveValidTokens(refreshToken, []);
Expand Down Expand Up @@ -229,7 +229,7 @@
* Makes a request as specified by the options.
* By default, this will:
* - use content-type: application/json
* - assume the HTTP GET method

Check warning on line 232 in src/apiv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @example
* const res = apiv2.request<ResourceType>({
Expand Down Expand Up @@ -268,7 +268,7 @@
}
try {
return await this.doRequest<ReqT, ResT>(internalReqOptions);
} catch (thrown: any) {

Check warning on line 271 in src/apiv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
if (thrown instanceof FirebaseError) {
throw thrown;
}
Expand All @@ -277,7 +277,7 @@
if (thrown instanceof Error) {
err = thrown;
} else {
err = new Error(thrown);

Check warning on line 280 in src/apiv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string | undefined`
}
throw new FirebaseError(`Failed to make request: ${err.message}`, { original: err });
}
Expand Down Expand Up @@ -365,7 +365,13 @@
}

if (options.signal) {
fetchOptions.signal = options.signal;
fetchOptions.signal = {
...options.signal,
reason: "",
throwIfAborted: () => {
throw new FirebaseError("Aborted");
},
};
}

let reqTimeout: NodeJS.Timeout | undefined;
Expand All @@ -374,7 +380,13 @@
reqTimeout = setTimeout(() => {
controller.abort();
}, options.timeout);
fetchOptions.signal = controller.signal;
fetchOptions.signal = {
...controller.signal,
reason: "",
throwIfAborted: () => {
throw new FirebaseError("Aborted");
},
};
}

if (typeof options.body === "string" || isStream(options.body)) {
Expand Down Expand Up @@ -414,8 +426,8 @@
this.logRequest(options);
try {
res = await fetch(fetchURL, fetchOptions);
} catch (thrown: any) {

Check warning on line 429 in src/apiv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
const err = thrown instanceof Error ? thrown : new Error(thrown);

Check warning on line 430 in src/apiv2.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string | undefined`
logger.debug(
`*** [apiv2] error from fetch(${fetchURL}, ${JSON.stringify(fetchOptions)}): ${err}`,
);
Expand Down
9 changes: 8 additions & 1 deletion src/emulator/auth/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
BlockingFunctionEvents,
} from "./state";
import { MfaEnrollments, Schemas } from "./types";
import { FirebaseError } from "../../error";

/**
* Create a map from IDs to operations handlers suitable for exegesis.
Expand Down Expand Up @@ -3134,7 +3135,13 @@ async function fetchBlockingFunction(
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(reqBody),
signal: controller.signal,
signal: {
...controller.signal,
reason: "",
throwIfAborted: () => {
throw new FirebaseError("Aborted");
},
},
});
ok = res.ok;
status = res.status;
Expand Down
9 changes: 8 additions & 1 deletion src/emulator/taskQueue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import AbortController from "abort-controller";
import { EmulatorLogger } from "./emulatorLogger";
import { RetryConfig, Task, TaskQueueConfig } from "./tasksEmulator";
import { Emulators } from "./types";
import { FirebaseError } from "../error";
import fetch from "node-fetch";

class Node<T> {
Expand Down Expand Up @@ -293,7 +294,13 @@ export class TaskQueue {
headers["X-CloudTasks-TaskPreviousResponse"] = `${emulatedTask.metadata.previousResponse}`;
}
const controller = new AbortController();
const signal = controller.signal;
const signal = {
...controller.signal,
reason: "",
throwIfAborted: () => {
throw new FirebaseError("Aborted");
},
};
const request = fetch(emulatedTask.task.httpRequest.url, {
method: "POST",
headers: headers,
Expand Down
Loading