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 3 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
@@ -1,2 +1,3 @@
- Updates reserved environment variables for CF3 to include 'EVENTARC_CLOUD_EVENT_SOURCE' (#4196).
- Fixes arg order for `firebase emulators:start --only storage` (#4195).
- 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 { 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 @@ -475,11 +475,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