Skip to content

[BUG] in sample: quickstarts/taskqueues-backup-images/functions/index.js #1002

Closed

Description

@ddave09

Which sample has a bug?

quickstarts/taskqueues-backup-images/functions/index.js

I have created my own queue with minor modifications provided in the Failing Function code used section. If someone can please help resolve the issue, I would really appreciate it.

Sample name or URL where you found the bug
quickstarts/taskqueues-backup-images/functions/index.js

How to reproduce the issue

  • create an index.ts file for functions with the below-mentioend code.
  • Deploy executeOrders function to create the queue with the same name.
  • execute submitOrder function.
  • enqueue fails with message: Unhandled error FirebaseFunctionsError: Queue does not exist.

Failing Function code used (if you modified the sample)

import * as functions from "firebase-functions";
import * as firebaseAdmin from "firebase-admin";
import * as firebaseFunctions from "firebase-admin/functions";
import * as serviceAccount from "../serviceAccount.json";

firebaseAdmin.initializeApp({
  credential: firebaseAdmin.credential.cert({
    projectId: serviceAccount.project_id,
    clientEmail: serviceAccount.client_email,
    privateKey: serviceAccount.private_key,
  }),
});

export const executeOrders = functions.region(
    region,
).tasks.taskQueue({
  retryConfig: {
    maxAttempts: 2,
    minBackoffSeconds: 10,
  },
  rateLimits: {
    maxConcurrentDispatches: 1,
  },
}).onDispatch(async (data) => {
  functions.logger.info(data);
});

export const submitOrder = functions.region(
    region,
).https.onCall(async (data, context) => {
  const queue = firebaseFunctions.getFunctions().taskQueue("executeOrders");

  functions.logger.info(data);

  await queue.enqueue({"orderId": 1});
});

I also have tried to pass in the app object returned from firebaseAdmin.initializeApp to firebaseFunctions.getFunctions() as below, but still the same behavior.

const firebaseAdminApp  = firebaseAdmin.initializeApp({
  credential: firebaseAdmin.credential.cert({
    projectId: serviceAccount.project_id,
    clientEmail: serviceAccount.client_email,
    privateKey: serviceAccount.private_key,
  }),
});

export const submitOrder = functions.region(
    region,
).https.onCall(async (data, context) => {
  const queue = firebaseFunctions.getFunctions(firebaseAdminApp).taskQueue("executeOrders");

  functions.logger.info(data);

  await queue.enqueue({"orderId": 1});
});

Steps to set up and reproduce

  • Env: node@16
  • Typescript
  • Deploy queue executeOrders
  • Start function emulator or without emulator (I have tried both ways but I get the same behavior.)
  • From any client call submitOrder function to enqueue a task in the executeOrders queue.
  • Function throws an error when enqueuing the task: Unhandled error FirebaseFunctionsError: Queue does not exist. even when the queue exists.

Debug output

{"severity":"ERROR","message":"Unhandled error FirebaseFunctionsError: Queue does not exist.\n    at FirebaseFunctionsError.FirebaseError [as constructor] (/Users/darshitdave/Documents/Workspace/youvest/youvest/functions/node_modules/firebase-admin/lib/utils/error.js:44:28)\n    at FirebaseFunctionsError.PrefixedFirebaseError [as constructor] (/Users/darshitdave/Documents/Workspace/youvest/youvest/functions/node_modules/firebase-admin/lib/utils/error.js:90:28)\n    at new FirebaseFunctionsError (/Users/darshitdave/Documents/Workspace/youvest/youvest/functions/node_modules/firebase-admin/lib/functions/functions-api-client-internal.js:269:28)\n    at FunctionsApiClient.toFirebaseError (/Users/darshitdave/Documents/Workspace/youvest/youvest/functions/node_modules/firebase-admin/lib/functions/functions-api-client-internal.js:243:16)\n    at /Users/darshitdave/Documents/Workspace/youvest/youvest/functions/node_modules/firebase-admin/lib/functions/functions-api-client-internal.js:101:25\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)\n    at async /Users/darshitdave/Documents/Workspace/youvest/youvest/functions/lib/src/index.js:182:5\n    at async /Users/darshitdave/Documents/Workspace/youvest/youvest/functions/node_modules/firebase-functions/lib/common/providers/https.js:407:26\n    at async runFunction (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:564:9)\n    at async runHTTPS (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:590:5) {\n  errorInfo: {\n    code: 'functions/failed-precondition',\n    message: 'Queue does not exist.'\n  },\n  codePrefix: 'functions'\n}"}

Screenshots

Expected behavior

The task should be enqueued under executeOrders queue.

Actual behavior

Error message: Unhandled error FirebaseFunctionsError: Queue does not exist. even when the queue executeOrders exists.

Activity

  1. craeft-io commented on Oct 9, 2023

    @craeft-io

    For me I can get around the error with specifying the location of the queue by replacing
    .taskQueue("executeOrders");
    with
    .taskQueue("location/us-east1/functions/executeOrders");

    Unfortunately with this working I get the error Request is missing body.

    I got it to work the same way as described here by creating a separate onRequest function
    #1105

  2. jhuleatt commented on Oct 7, 2026

    @jhuleatt
    Contributor

    Closing now that #1341 is merged. The cause: getFunctions().taskQueue("name") assumes us-central1 when you pass a bare function name. For a function in another region, pass the full resource name (plural locations):

    getFunctions().taskQueue("locations/europe-west1/functions/backupapod")

    The samples deploy to us-central1 on purpose so the defaults line up, and both task queue READMEs now say so. Thanks for the detailed thread.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions