firebase-admin-node
firebase-admin-node copied to clipboard
[messaging] TypeError: Value is not an object: undefined
[REQUIRED] Step 2: Describe your environment
- Operating System version: MongoDB Atlas Trigger (Realm App)
- Firebase SDK version: 11.4.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 and is not working anymore after upgrading to firebase-admin: 11.4.1 from 11.0.1 and with the release of fastify/busboy 1.2.0 :
uncaught promise rejection: TypeError: Value is not an object: undefined
The difference with my previous issue #1902 is that now messaging().sendMulticat(message) is crashing and no longer deliver the push notification.
Steps to reproduce:
- Create a MongoDB Atlas trigger
- Add
firebase-adminas external dependency and make sure it's11.4.1 - Add the service-account.json as a
value - 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 !");
}
}
I have rolled back to 11.0.1 to see the difference and i am getting the following error :
TypeError: Arguments must be Buffers
at compare (<eval>:344:13(19))
at node_modules/@fastify/busboy/deps/streamsearch/sbmh.js:181:65(304)
at node_modules/@fastify/busboy/deps/streamsearch/sbmh.js:82:24(41)
at node_modules/@fastify/busboy/deps/dicer/lib/Dicer.js:107:23(92)
at T (<eval>:10:22717(45))
at <eval>:10:25821(108)
at <eval>:10:25847(113)
at d (<eval>:10:14414(11))
at <eval>:10:4454(115)
at <eval>:10:13336(285)
at C (<eval>:10:11803(20))
at A (<eval>:10:11681(31))
But the push notification is sent successfully, in 11.4.1 it's not sent at all.
I'm seeing the same issue, where updating from 11.4.0 to 11.4.1 is causing this crash. It appears that this change has pushed 'undefined' as a value into a the JWT verify flow, which might match the error. I will try to get my function dependencies to refresh, as it might be a stale package (jsonwebtoken) causing the failure.
No change in behavior after adding jsonwebtoken 9.0.0 as a dependency directly.
Same issue here... Works perfectly with 11.0.1
Hey folks, thank you for reporting this! Are you able to share the complete error logs with us? If you can reproduce the issue in a simple Node.js project, could you provide us with a minimal repro, please?
Sorry i don't know node JS that much, i only use a MongoDB Atlas Trigger to see this behavior... :(
No worries, are you able to share a complete error log so we can track down where it is throwing the error?
@lahirumaramba the errors posted above are all that are given when the error is generated by the MongoDB function, apologies.
If it helps, here are a couple extra details:
payload:
{"notification":{"body":"Your video is ready!","title":"New Video"},"tokens":[<my-device-token>]}
call:
const admin = require('firebase-admin');
admin.messaging().sendMulticast(message)
No worries, are you able to share a complete error log so we can track down where it is throwing the error?
Sorry for the late answer, there is no more logs than this from the Atlas trigger... However, i think it can be related to any changes made between the working version and this one that is not working at all.
Has there been any progress on this? I'm still running into this issue on version 11.7.0
I have the same issue, are there any news about this topic? Actually using version 11.9.0.
11.10.1, also using MongoDB Atlas functions, same error :/
Did anyone every resolve this? Using version 11.11.0 in MongoDB Atlas functions and still getting same error...
I downgraded to v10.0.0 and it works well.
I can't believe that this has still not been fixed😟. (now using 12.0.0)
Still no update on this?
I get the same error when using 12.0.0. Had to downgrade to 10.0.0 for it to work.
Same issue here, 10.0.0 is working but 12 is not.
im using the last version 12.1.1 and i have the same issue, did you know any workaroud?