firebase-admin-node: [messaging] http module : failed to execute source

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

  • For issues related to the code in this repository file a Github issue.
  • If the issue pertains to Cloud Firestore, read the instructions in the “Firestore issue” template.
  • 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: MongoDB Atlas Trigger (Realm App)
  • Firebase SDK version: 11.0.1
  • Firebase Product: messaging
  • JS SDK Version: 3.18.0
  • NPM version: I don’t know

[REQUIRED] Step 3: Describe the problem

Executing admin.messaging().sendMulticast(message) returns an error but is actually working :

FunctionError: 'http' module: FunctionError: failed to execute source for 'node_modules/@fastify/busboy/lib/main.js': FunctionError: failed to execute source for 'node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js': FunctionError: failed to execute source for 'node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js': FunctionError: failed to execute source for 'node_modules/@fastify/busboy/lib/utils.js': TypeError: Value is not an object: undefined
    at node_modules/@fastify/busboy/lib/utils.js:23:27(322)

    at require (native)
    at node_modules/@fastify/busboy/deps/dicer/lib/HeaderParser.js:15:24(29)

    at require (native)
    at node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js:19:28(39)

    at require (native)
    at node_modules/@fastify/busboy/lib/main.js:28:21(44)

    at execute (native)
    at <eval>:16:29(8)
    at K (<eval>:10:6625(35))
    at <eval>:10:4454(115)
    at M (<eval>:10:9199(23))
    at T (<eval>:10:9026(174))
    at <eval>:10:9810(49)
    at onStreamRead (<eval>:10:2062(36))

My Atlas Trigger reports error anyway even if the code is successfully executed.

Here is my StackOverflow bounty on the subject but since no one has an obvious answer i have decided to raise an issue here.

Steps to reproduce:

  1. Create a MongoDB Atlas trigger
  2. Add firebase-admin as external dependency
  3. Add the service-account.json as a value
  4. Run the code with the below code

Relevant Code:

exports = async function() {

  const admin = require("firebase-admin");
  const json_creds = context.values.get("service_account_value_name");
  	  
    const title = "Test";
    const body = "This is a test";
   
    const message= {
      android: {
        notification: {
          title: title,
          sound: "default",
          body: body,
        },
      },
      apns: {
        payload: {
          aps: {
            alert: {
              title: title,
              body: body,
            },
            mutableContent: 1,
            contentAvailable: 1
          }
        },
      },
      tokens: ["device_token_1", "device_token_2"]
    };
    	
    admin.initializeApp({
        credential: admin.credential.cert(JSON.parse(json_creds))
      });
  
    admin.messaging().sendMulticast(message);

    console.log("Messages sent !");
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 25 (5 by maintainers)

Most upvoted comments

Closing this as the issue is now fixed in fastify/busboy v1.2.0 (Thanks folks!) https://github.com/fastify/busboy/issues/100 We can reopen later if needed.

We do not pin to a specific version of @fastify/busboy in firebase-admin so if you do a fresh install of firebase-admin npm should pull the latest version of @fastify/busboy. https://github.com/firebase/firebase-admin-node/blob/88ae832ac86bbdd015a7c859e6fa09f467391dfb/package.json#L199

The easiest way to do this is by removing your node_modules and package-lock.json and then running npm install. Keep in mind though that this might update other dependencies in your project.

You might also be able to force the package version of @fastify/busboy using resolutions key or overrides (in NPM 8+) in package.json.

I am not super familiar with Atlas triggers. If you do not deploy the package-lock file then it is possible that the Atlas triggers do a fresh install of firebase-admin when your triggers are deployed or re-created/updated and that should also install the latest version of @fastify/busboy.

@lahirumaramba

If you can provide a PR, I would gladly look in to it.

I will have a look at it latest on monday.

@Tom3652 Yup, looks like we’ve got it: App Services does not support [util.TextDecoder](https://nodejs.org/docs/v10.18.1/api/util.html#util_class_util_textdecoder), which we are using. @Uzlopak what’s your take on this?