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

Fix bug where functions.runtime option in firebase.json is ignored in the Emulator #4207

Merged
merged 5 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
- Fixes an issue in the storage emulator where a file upload would trigger functions with a metadata update handler (#4213).
- Fixes Storage Emulator rules resource evaluation (#4214).
- Fixes bug where securityLevel is overwritten on https function re-deploys (#4208).
- Fixes bug where functions emulator ignored functions.runtime option in firebase.json (#4207).
16 changes: 10 additions & 6 deletions src/emulator/functionsEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import * as clc from "cli-color";
import * as http from "http";
import * as jwt from "jsonwebtoken";
import * as cors from "cors";
import * as stream from "stream";
import { URL } from "url";
import { EventEmitter } from "events";

import { Account } from "../auth";
import * as api from "../api";
Expand Down Expand Up @@ -41,8 +43,6 @@ import {
emulatedFunctionsByRegion,
} from "./functionsEmulatorShared";
import { EmulatorRegistry } from "./registry";
import { EventEmitter } from "events";
import * as stream from "stream";
import { EmulatorLogger, Verbosity } from "./emulatorLogger";
import { RuntimeWorker, RuntimeWorkerPool } from "./functionsRuntimeWorker";
import { PubsubEmulator } from "./pubsubEmulator";
Expand All @@ -58,10 +58,10 @@ import {
import { EventUtils } from "./events/types";
import { functionIdsAreValid } from "../deploy/functions/validate";
import { Extension, ExtensionSpec, ExtensionVersion } from "../extensions/extensionsApi";
import { getRuntimeDelegate } from "../deploy/functions/runtimes";
import { accessSecretVersion } from "../gcp/secretManager";
import * as runtimes from "../deploy/functions/runtimes";
import * as backend from "../deploy/functions/backend";
import * as functionsEnv from "../functions/env";
import { accessSecretVersion } from "../gcp/secretManager";

const EVENT_INVOKE = "functions:invoke";
const LOCAL_SECRETS_FILE = ".secret.local";
Expand Down Expand Up @@ -480,11 +480,15 @@ export class FunctionsEmulator implements EmulatorInstance {
triggerDefinitions = emulatedFunctionsByRegion(emulatableBackend.predefinedTriggers);
} else {
const runtimeConfig = this.getRuntimeConfig(emulatableBackend);
const runtimeDelegate = await getRuntimeDelegate({
const runtimeDelegateContext: runtimes.DelegateContext = {
projectId: this.args.projectId,
projectDir: this.args.projectDir,
sourceDir: emulatableBackend.functionsDir,
});
};
if (emulatableBackend.nodeMajorVersion) {
runtimeDelegateContext.runtime = `nodejs${emulatableBackend.nodeMajorVersion}`;
}
const runtimeDelegate = await runtimes.getRuntimeDelegate(runtimeDelegateContext);
logger.debug(`Validating ${runtimeDelegate.name} source`);
await runtimeDelegate.validate();
logger.debug(`Building ${runtimeDelegate.name} source`);
Expand Down