[go: nahoru, domu]

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

Detect changes in eventTrigger definitions #3557

Merged
merged 3 commits into from
Jul 8, 2021
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
Next Next commit
Detect changes in eventTrigger definitions
  • Loading branch information
samtstern committed Jul 7, 2021
commit f73c9f2930451af0ff02594461bbbe08f8e7a6b7
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
- Firestore Emulator UI now supports deleting documents and collections recursively.
- Fixes some Storage Emulator UI errors.
- Fixes some issues when using Emulator UI on a different device.
- Fixes Emulator issue when function definition changes (#2533).
20 changes: 18 additions & 2 deletions src/emulator/functionsEmulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
AdminSdkConfig,
constructDefaultAdminSdkConfig,
} from "./adminSdkConfig";
import { recorder } from "nock/types";

const EVENT_INVOKE = "functions:invoke";

Expand Down Expand Up @@ -432,9 +433,24 @@ export class FunctionsEmulator implements EmulatorInstance {
}

// We want to add a trigger if we don't already have an enabled trigger
// with the same entryPoint.
// with the same entryPoint / trigger.
const anyEnabledMatch = Object.values(this.triggers).some((record) => {
return record.def.entryPoint === definition.entryPoint && record.enabled;
const sameEntryPoint = record.def.entryPoint === definition.entryPoint;

// If they both have event triggers, make sure they match
const sameEventTrigger =
JSON.stringify(record.def.eventTrigger) === JSON.stringify(definition.eventTrigger);

if (sameEntryPoint && !sameEventTrigger) {
this.logger.log(
"DEBUG",
`Definition for trigger ${definition.entryPoint} changed from ${JSON.stringify(
record.def.eventTrigger
)} to ${JSON.stringify(definition.eventTrigger)}`
);
}

return record.enabled && sameEntryPoint && sameEventTrigger;
});
return !anyEnabledMatch;
});
Expand Down