3

The firebase extension for a distributed counter can be directly installed for the cloud and works just fine. To develop new features for an app I need to do this on the emulator to not interrupt the running server.

As the firebase extensions simply are cloud Functions*, I thought about implementing the cloud function in my emulator by getting the source code from the extension itself. This worked fine for other extentions so far...

Error and Disfunction when implementing

When implementing the javaScript version that i get the following error:

function ignored because the unknown emulator does not exist or is not running.

This problem can be fixed by rewriting the export line of the index.jsfunctions, but is wont provide the expected functionality of the extension anyhow:

exports.worker = functions.handler.firestore.document.onWrite(async (change, context) => {...});

to

exports.worker = functions.firestore.document("").onWrite(async (change, context) => {...});

Question

Am i missing some implementaion or is an emulator missing? How can i implement this firestore extention?

There are some similar questions, but dont really talk about the implementation of the whole extension:

Paul
  • 1,349
  • 1
  • 14
  • 26

1 Answers1

10

firebaser here

Update: The Firebase Emulator Suite now supports emulating extensions! To emulate this extension, first you'll need to add it to your extension manifest. The easiest way to do this is, from your local firebase directory, to run:

firebase ext:install firebase/firestore-counter

Then, next time you start up the emulators, the code for the extension will be downloaded and emulated.

One thing to note is that the Distributed counter extension uses a scheduled function. The emulator suite doesn't trigger these for you, so you'll have to trigger them yourself by sending a PubSub message to the PubSub emulator. This answer does a good job explaining how to do this

Joe Hanley
  • 191
  • 1
  • 4