You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Upgrade from 11.11.1 to 12.0.0 and change from sendAll to sendEach throwing errors #2418
Hello,
I've upgraded to latest version of firebase-admin and got some deprecation method messages. One of them was sendAll which is gonna be replaced with sendEach. I checked interfaces and description provided in firebase-admin and it look same. But after switching to new sendEach method I started to get errors like
Rejected unknown error: {\"code\":\"app/invalid-credential\",\"message\":\"Failed to determine project ID: Error while making request: getaddrinfo ENOTFOUND metadata.google.internal. Error code: ENOTFOUND\"}
Firebase SDK version: 12.0.0
Firebase Product: messaging
Node.js version: 20.10.0
NPM version: 10.2.5
What has changed? Is there different approach to authorisation or something else needed to be changed? Is there any migration guide for upgrade from v11 to v12?
Also while debugging I have noticed circular dependency at
firebase-admin have dependency "@firebase/database-compat": "^1.0.2",
and database-compat have dependency back to "firebase-admin": "11.6.0",
It's not with switch to v12, that upgrade gave us only deprecation message on fcm.messaging.sendAll.. The problem is when we switch from fcm.messaging.sendAll to fcm.messaging.sendEach
Cleaned a lot.. but its visible from it hopefully - "working way"
import fcm, { messaging as fcmTypes, FirebaseError } from 'firebase-admin';
public async sendBulk(items: any[]): Promise<any> {
const fcmApp = fcm.apps?.find((app) => app?.name === credentials.credentialsId) ?? // this we have in config
fcm.initializeApp(
{
credential: fcm.credential.cert(credentials),
},
credentials.credentialsId);
fcm
.messaging(fcmApp)
// eslint-disable-next-line deprecation/deprecation -- this is deprecated method, we need to switch to .sendEach
.sendAll(items)
.then(({ responses }) => { // do some logic })
.catch((error) => { // do some logic});
}
and when we switch to .sendEach, we start getting that mentioned error
import fcm, { messaging as fcmTypes, FirebaseError } from 'firebase-admin';
public async sendBulk(items: any[]): Promise<any> {
const fcmApp = fcm.apps?.find((app) => app?.name === credentials.credentialsId) ?? // this we have in config
fcm.initializeApp(
{
credential: fcm.credential.cert(credentials),
},
credentials.credentialsId);
fcm
.messaging(fcmApp)
.sendEach(items)
.then(({ responses }) => { // do some logic })
.catch((error) => { // do some logic});
}
Thank you this helped.. Before it did not help because we had bad setup of tests which I fixed with this.. Thank you.. Anyway, is there any reason why sendEach is calling RPC one by one? Instead of sendAll where it sent all at once? Its 2-2.5 times slower than sendAll :( Thank you
The backend API that was used by sendAll has been deprecated so we had to re implement the functionality using the send API, which sends multiple requests to the backend. We are aware of the performance issues and looking for ways to further optimize the functionality. Stay tuned!
Hi!
Any progress on this?
After migrate to sendEach i have been noticed with my IT team that change decrease the performance but also considerably increases the cost of the server, we need to use many more threads to achieve the same performance.
Hey @dpereiraegoi,
With v12.3.0, sendEach() and sendEachForMulitcast() now use a HTTP/2 connection by default when sending messages. This should provide some performance improvements.
With the deprecation of the batch FCM backend endpoints, each message requires a request to be sent to the backend which explains the increase in threads. This is a limitation of not having a batch endpoint and is beyond the scope of this SDK which is essentially a wrapper for the REST API.
If you continue to experience considerably decreased performance after upgrading to HTTP/2, I'd recommend filing a Firebase support ticket from https://firebase.google.com/support/troubleshooter/contact to share your feedback to reach the correct internal teams.
Activity
dweissjcs commentedon Jan 3, 2024
Also while debugging I have noticed circular dependency at
firebase-admin have dependency
"@firebase/database-compat": "^1.0.2",and
database-compathave dependency back to"firebase-admin": "11.6.0",dweissjcs commentedon Jan 19, 2024
bump
lahirumaramba commentedon Mar 5, 2024
There were no changes to the credentials handling in v12. How do you initialize the SDK? Are you able to share some code samples with us?
dweissjcs commentedon Mar 6, 2024
It's not with switch to v12, that upgrade gave us only deprecation message on
fcm.messaging.sendAll.. The problem is when we switch fromfcm.messaging.sendAlltofcm.messaging.sendEachCleaned a lot.. but its visible from it hopefully - "working way"
and when we switch to .sendEach, we start getting that mentioned error
lahirumaramba commentedon Mar 7, 2024
Interesting... can you try adding
projectIdto see if that solves the issue?dweissjcs commentedon Mar 8, 2024
Thank you this helped.. Before it did not help because we had bad setup of tests which I fixed with this.. Thank you.. Anyway, is there any reason why sendEach is calling RPC one by one? Instead of sendAll where it sent all at once? Its 2-2.5 times slower than sendAll :( Thank you
lahirumaramba commentedon Mar 11, 2024
The backend API that was used by
sendAllhas been deprecated so we had to re implement the functionality using thesendAPI, which sends multiple requests to the backend. We are aware of the performance issues and looking for ways to further optimize the functionality. Stay tuned!(@jonathanedey FIY)
marcel-happyfloat commentedon Apr 28, 2024
When will
sendAllstop working?LebonNic commentedon May 14, 2024
I think it will stop working on June 20, 2024: https://firebase.google.com/support/faq/#fcm-depr-features
jandryml commentedon Aug 22, 2024
any progress on this?
dpereiraegoi commentedon Sep 19, 2024
Hi!
Any progress on this?
After migrate to sendEach i have been noticed with my IT team that change decrease the performance but also considerably increases the cost of the server, we need to use many more threads to achieve the same performance.
jonathanedey commentedon Sep 19, 2024
Hey @dpereiraegoi,
With v12.3.0,
sendEach()andsendEachForMulitcast()now use a HTTP/2 connection by default when sending messages. This should provide some performance improvements.With the deprecation of the batch FCM backend endpoints, each message requires a request to be sent to the backend which explains the increase in threads. This is a limitation of not having a batch endpoint and is beyond the scope of this SDK which is essentially a wrapper for the REST API.
If you continue to experience considerably decreased performance after upgrading to HTTP/2, I'd recommend filing a Firebase support ticket from https://firebase.google.com/support/troubleshooter/contact to share your feedback to reach the correct internal teams.