Skip to content

Commit

Permalink
Fix bug where functions.runtime option in firebase.json is ignored in…
Browse files Browse the repository at this point in the history
… the Emulator (#4207)

Fixes #4200
  • Loading branch information
taeold committed Feb 28, 2022
1 parent 4349494 commit 2948555
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
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

0 comments on commit 2948555

Please sign in to comment.