简体   繁体   中英

How do I emulate enqueuing a Google Cloud Task from inside a Firebase function?

My code

Hey, I'm using the Firebase Emulator to emulate Firebase's Firestore. Functions and Authentication, By following the documentation, Enqueue functions with Cloud Tasks , I created a task queue named removeGroupCode() :

exports.removeGroupCode = functions.tasks
  .taskQueue({
    .
    .
    .
  })
  .onDispatch(async (data) => {
    .
    .
    .
    }
  });

The problem

This removeGroupCode() function works fine both in production and in the local emulator. But for some reason it just doesn't get called when I'm calling it from another function in the local emulator:

exports.generateInviteCode = functions.https.onCall(async (data, context) => {
  .
  .
  .
  const queue = getFunctions(app).taskQueue("removeGroupCode");
  await queue.enqueue(
    {groupCode: groupCode},
    {scheduleDelaySeconds: 30, dispatchDeadlineSeconds: 60},
  );
  return {groupCode: groupCode};
});

Note: The above code also works fine in production, but I still would like it to work in the emulated environment for testing purposes.

Question

Could it be that for some reason the Firebase Emulator ignores this call because this isn't a feature in the library yet? Or am I missing here?

As per above comments

There is a feature request raised for this at github . Which is still open further progress can be tracked there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM