Skip to content

"Requested entity not found" for half of the messages sent trough FCM #561

@guikaercher

Description

@guikaercher

[READ] Step 1: Are you in the right place?

  • For issues or feature requests related to the code in this repository
    file a Github issue.
    • If this is a feature request make sure the issue title starts with "FR:".
  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Operating System version: Running at lambda AWS / Node
  • Firebase SDK version: "firebase-admin": "^7.0.0"
  • Library version: ?
  • Firebase Product: FCM (auth, database, storage, etc)

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

We are sending about 30k pushes to devices, 50% of this messages (iOS and Android) receives this error as response. We've already tried:

  • Generating new tokens for devices we own.
  • Change to debug/release projects.

Error: Requested entity was not found.
at FirebaseMessagingError.FirebaseError [as constructor] (/var/task/node_modules/firebase-admin/lib/utils/error.js:42:28)
at FirebaseMessagingError.PrefixedFirebaseError [as constructor] (/var/task/node_modules/firebase-admin/lib/utils/error.js:88:28)
at new FirebaseMessagingError (/var/task/node_modules/firebase-admin/lib/utils/error.js:253:16)
at Function.FirebaseMessagingError.fromServerError (/var/task/node_modules/firebase-admin/lib/utils/error.js:283:16)
at Object.createFirebaseError (/var/task/node_modules/firebase-admin/lib/messaging/messaging-errors.js:34:47)
at /var/task/node_modules/firebase-admin/lib/messaging/messaging-api-request.js:76:42
at
at process._tickDomainCallback (internal/process/next_tick.js:228:7)

Relevant Code:

let unifiedFirebase: app.App;

const initializeFirebases = async () => {
  const { iosParameters, unifiedFirebaseParameters } = await initializeParameters();
  await elk.info('Intializing firebase');
  if (!iosFirebase) {
    iosFirebase = await initializeGoogleServices(iosParameters,
                                                 'project_name_removed');
  }
  if (!unifiedFirebase) {
    unifiedFirebase = await initializeGoogleServices(unifiedFirebaseParameters,
                                                     'project_name_removed');
  }
  await elk.info('Intialized firebase');
};


const sendAndroidPush = async (androidToken: any, pushData: pushData, payload: any) => {
  const { title, body } = pushData;
  try {
    await sendPushMessage(title, body, androidToken, payload, unifiedFirebase, false);
    return true;
  } catch (e) {
    const errorDetails: any = Object.assign(pushData, {});
    errorDetails.stackTrace = e.stack || null;
    await elk.error('error_android_send_push', errorDetails);
    return false;
  }
};

const sendPushMessage = async (title:string, body:string, token:string, data: any,
                               firebaseApp: app.App, isTest:boolean) => {

  const message: FirebaseMessage = {
    token,
    notification : {
      title,
      body,
    },
  };

  if (data && Object.keys(data).length > 0) message.data = data;

  return firebaseApp.messaging().send(message, isTest);
};

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