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

Extensions with scheduled triggers not supported. PR created ✔ #5374

Closed
stfsy opened this issue Dec 27, 2022 · 7 comments
Closed

Extensions with scheduled triggers not supported. PR created ✔ #5374

stfsy opened this issue Dec 27, 2022 · 7 comments

Comments

@stfsy
Copy link
Contributor

stfsy commented Dec 27, 2022

[REQUIRED] Environment info

firebase-tools: 11.19.0

Platform: Windows

[REQUIRED] Test case

There is a new unit test case in #5373

[REQUIRED] Steps to reproduce

  • Use a Windows machine
  • Install firebase-tools
  • Install firestore-counter extension
  • Start the emulator
  • Logs say that function controllerCore was ignored because of an unknown trigger

[REQUIRED] Expected behavior

Extensions with scheduled trigger are also supported by the emulator.

[REQUIRED] Actual behavior

Extensions with scheduled trigger are also supported by Emulator.

The triggerHelper module defines which triggers are supported. The scheduleTrigger is currently not handled and therefore not supported.

if (properties.httpsTrigger) {
etd.httpsTrigger = properties.httpsTrigger;
}
if (properties.eventTrigger) {
etd.eventTrigger = {
eventType: properties.eventTrigger.eventType,
resource: properties.eventTrigger.resource,
service: getServiceFromEventType(properties.eventTrigger.eventType),
};
} else {
EmulatorLogger.forEmulator(Emulators.FUNCTIONS).log(
"WARN",
`Function '${resource.name} is missing a trigger in extension.yaml. Please add one, as triggers defined in code are ignored.`
);
}

To be able to use extensions like firebase-counter in the emulator and without modifications we need support for scheduleTriggers. I created PR #5373 which converst the scheduleTrigger to a pubSub trigger which in turn can be triggered by writing to the pubsub topic.

@stfsy stfsy added the bug label Dec 27, 2022
@google-oss-bot
Copy link
Contributor

This issue does not have all the information required by the template. Looks like you forgot to fill out some sections. Please update the issue with more information.

@stfsy
Copy link
Contributor Author

stfsy commented Dec 27, 2022

@polarby because of firebase/extensions#876, i saw you are also using the counter extension in the emulator. Thought you might be interested as well

@stfsy stfsy changed the title Extensions with scheduled triggers not supported Extensions with scheduled triggers not supported. PR created ✔ Dec 27, 2022
@polarby
Copy link

polarby commented Dec 27, 2022

If you need to run functions with a low frequency (once every hour/day..) you can usually run those functions manually (as you also most likely won't have the emulator running for that time). Tasks that require high-frequency emulation, will be more challenging to handle and likely need support for scheduled functions from the firebase team.

Low-frequency functions (manual emulation)

Run the terminal in your project directory

$  firebase functions:shell

It will show all your callable functions, including your scheduled ones. Run those by calling them:

yourScheduledFunc();

@stfsy
Copy link
Contributor Author

stfsy commented Dec 27, 2022

@polarby thank you. Appreciate it.

In this case the controllerCore function is not even recognized as a callable function by the emulator. It is completey ignored because of the unknown trigger and therefore does not get loaded/instantiated at all 😞

@polarby
Copy link

polarby commented Dec 27, 2022

Yeah, that sure is a Problem. A workaround for now (and not too time-consuming) is for sure to copy-paste the source code of those emulated functions and then run them. But let's keep this issue open for the implementation of this essential feature!

@stfsy
Copy link
Contributor Author

stfsy commented Dec 27, 2022

Would it make sense to merge my PR in the mean time? Its not very invasive and at least enables the emulator to parse and instantiate the function, so that It can be triggered from the parent application without copying the source code.

@joehan
Copy link
Contributor

joehan commented Dec 29, 2022

Thanks for the contribution! Closing this since you added support.
We don't have any plans to real scheduled support to the emulator suite. Since most schedules are pretty impractical in an emulated environment, it makes more sense to manually trigger these functions for testing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants