Skip to content

Commit

Permalink
update node types package to 12 (#4005)
Browse files Browse the repository at this point in the history
* update node types package to 12

* a couple type issues...

* uncomment linking
  • Loading branch information
bkendall authored Jan 20, 2022
1 parent b705926 commit 6d291e8
Show file tree
Hide file tree
Showing 12 changed files with 1,155 additions and 1,909 deletions.
2,993 changes: 1,113 additions & 1,880 deletions npm-shrinkwrap.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
]
},
"dependencies": {
"@google-cloud/pubsub": "^2.7.0",
"@google-cloud/pubsub": "^2.18.4",
"abort-controller": "^3.0.0",
"ajv": "^6.12.6",
"archiver": "^5.0.0",
Expand Down Expand Up @@ -130,7 +130,7 @@
"stream-chain": "^2.2.4",
"stream-json": "^1.7.3",
"superstatic": "^7.1.0",
"tar": "^4.3.0",
"tar": "^6.1.11",
"tcp-port-used": "^1.0.1",
"tmp": "0.0.33",
"triple-beam": "^1.3.0",
Expand Down Expand Up @@ -169,7 +169,7 @@
"@types/marked-terminal": "^3.1.3",
"@types/mocha": "^9.0.0",
"@types/multer": "^1.4.3",
"@types/node": "^10.17.50",
"@types/node": "^12.20.39",
"@types/node-fetch": "^2.5.7",
"@types/progress": "^2.0.3",
"@types/puppeteer": "^5.4.2",
Expand All @@ -180,7 +180,7 @@
"@types/sinon-chai": "^3.2.2",
"@types/stream-json": "^1.7.2",
"@types/supertest": "^2.0.6",
"@types/tar": "^4.0.0",
"@types/tar": "^6.1.1",
"@types/tcp-port-used": "^1.0.0",
"@types/tmp": "^0.1.0",
"@types/triple-beam": "^1.3.0",
Expand Down
4 changes: 2 additions & 2 deletions scripts/integration-helpers/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export class CLIProcess {
}
this.process = p;

this.process.stdout.on("data", (data: unknown) => {
this.process.stdout?.on("data", (data: unknown) => {
process.stdout.write(`[${this.name} stdout] ` + data);
});

this.process.stderr.on("data", (data: unknown) => {
this.process.stderr?.on("data", (data: unknown) => {
console.log(`[${this.name} stderr] ` + data);
});

Expand Down
2 changes: 1 addition & 1 deletion scripts/integration-helpers/framework.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class TriggerEndToEndTest {
return data.includes(ALL_EMULATORS_STARTED_LOG);
});

cli.process?.stdout.on("data", (data) => {
cli.process?.stdout?.on("data", (data) => {
/* Functions V1 */
if (data.includes(RTDB_FUNCTION_LOG)) {
this.rtdbTriggerCount++;
Expand Down
2 changes: 1 addition & 1 deletion src/deploy/functions/runtimes/golang/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class Delegate {
cwd: this.sourceDir,
stdio: [/* stdin=*/ "ignore", /* stdout=*/ "pipe", /* stderr=*/ "inherit"],
});
childProcess.stdout.on("data", (chunk) => {
childProcess.stdout?.on("data", (chunk) => {
logger.debug(chunk.toString());
});
return Promise.resolve(async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/emulator/downloadableEmulators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,11 +325,11 @@ async function _runBinary(
`${description} logging to ${clc.bold(getLogFileName(emulator.name))}`
);

emulator.instance.stdout.on("data", (data) => {
emulator.instance.stdout?.on("data", (data) => {
logger.log("DEBUG", data.toString());
emulator.stdout.write(data);
});
emulator.instance.stderr.on("data", (data) => {
emulator.instance.stderr?.on("data", (data) => {
logger.log("DEBUG", data.toString());
emulator.stdout.write(data);

Expand Down
11 changes: 9 additions & 2 deletions src/emulator/functionsEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export interface FunctionsRuntimeInstance {
// A function to manually kill the child process as normal cleanup
shutdown(): void;
// A function to manually kill the child process in case of errors
kill(signal?: string): void;
kill(signal?: number): void;
// Send an IPC message to the child process
send(args: FunctionsRuntimeArgs): boolean;
}
Expand Down Expand Up @@ -1080,6 +1080,13 @@ export class FunctionsEmulator implements EmulatorInstance {
stdio: ["pipe", "pipe", "pipe", "ipc"],
});

if (!childProcess.stderr) {
throw new FirebaseError(`childProcess.stderr is undefined.`);
}
if (!childProcess.stdout) {
throw new FirebaseError(`childProcess.stdout is undefined.`);
}

const buffers: {
[pipe: string]: {
pipe: stream.Readable;
Expand Down Expand Up @@ -1113,7 +1120,7 @@ export class FunctionsEmulator implements EmulatorInstance {
shutdown: () => {
childProcess.kill();
},
kill: (signal?: string) => {
kill: (signal?: number) => {
childProcess.kill(signal);
emitter.emit("log", new EmulatorLog("SYSTEM", "runtime-status", "killed"));
},
Expand Down
22 changes: 14 additions & 8 deletions src/emulator/functionsEmulatorRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,10 +638,13 @@ async function initializeFirebaseAdminStubs(frb: FunctionsRuntimeBundle): Promis
.finalize();

// Stub the admin module in the require cache
require.cache[adminResolution.resolution] = {
exports: proxiedAdminModule,
path: path.dirname(adminResolution.resolution),
};
require.cache[adminResolution.resolution] = Object.assign(
require.cache[adminResolution.resolution],
{
exports: proxiedAdminModule,
path: path.dirname(adminResolution.resolution),
}
);

logDebug("firebase-admin has been stubbed.", {
adminResolution,
Expand Down Expand Up @@ -735,10 +738,13 @@ async function initializeFunctionsConfigHelper(frb: FunctionsRuntimeBundle): Pro
.finalize();

// Stub the functions module in the require cache
require.cache[functionsResolution.resolution] = {
exports: proxiedFunctionsModule,
path: path.dirname(functionsResolution.resolution),
};
require.cache[functionsResolution.resolution] = Object.assign(
require.cache[functionsResolution.resolution],
{
exports: proxiedFunctionsModule,
path: path.dirname(functionsResolution.resolution),
}
);

logDebug("firebase-functions has been stubbed.", {
functionsResolution,
Expand Down
6 changes: 3 additions & 3 deletions src/emulator/storage/rules/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class StorageRulesRuntime {
});

// This catches errors from the java process (i.e. missing jar file)
this._childprocess.stderr.on("data", (buf: Buffer) => {
this._childprocess.stderr?.on("data", (buf: Buffer) => {
const error = buf.toString();
if (error.includes("jarfile")) {
throw new FirebaseError(
Expand All @@ -166,7 +166,7 @@ export class StorageRulesRuntime {
}
});

this._childprocess.stdout.on("data", (buf: Buffer) => {
this._childprocess.stdout?.on("data", (buf: Buffer) => {
const serializedRuntimeActionResponse = buf.toString("UTF8").trim();
if (serializedRuntimeActionResponse != "") {
let rap;
Expand Down Expand Up @@ -225,7 +225,7 @@ export class StorageRulesRuntime {
};

const serializedRequest = JSON.stringify(runtimeActionRequest);
this._childprocess?.stdin.write(serializedRequest + "\n");
this._childprocess?.stdin?.write(serializedRequest + "\n");
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/hosting/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function makeVary(vary: string | null = ""): string {
* the Firebase Hosting origin.
*/
export function proxyRequestHandler(url: string, rewriteIdentifier: string): RequestHandler {
return async (req: IncomingMessage, res: ServerResponse, next: () => void): Promise<void> => {
return async (req: IncomingMessage, res: ServerResponse, next: () => void): Promise<unknown> => {
logger.info(`[hosting] Rewriting ${req.url} to ${url} for ${rewriteIdentifier}`);
// Extract the __session cookie from headers to forward it to the
// functions cookie is not a string[].
Expand Down
8 changes: 4 additions & 4 deletions src/test/apiv2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,11 @@ describe("apiv2", () => {
res.end(JSON.stringify({ proxied: true }));
});
await Promise.all([
new Promise((resolve) => {
proxyServer.listen(52672, resolve);
new Promise<void>((resolve) => {
proxyServer.listen(52672, () => resolve());
}),
new Promise((resolve) => {
targetServer.listen(52673, resolve);
new Promise<void>((resolve) => {
targetServer.listen(52673, () => resolve());
}),
]);
});
Expand Down
2 changes: 1 addition & 1 deletion src/test/emulators/functionsRuntimeWorker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MockRuntimeInstance implements FunctionsRuntimeInstance {
this.events.emit("exit", { reason: "shutdown" });
}

kill(signal?: string): void {
kill(signal?: number): void {
this.events.emit("exit", { reason: "kill" });
}

Expand Down

0 comments on commit 6d291e8

Please sign in to comment.