Skip to content

messaging.sendMulticast, sendAll rejects valid ttl #479

Closed
@stari4ek

Description

"firebase-admin": "^7.1.0",

When I'm sending message with ttl it got rejected while it's totally valid (number, >0)

const msg: firebase.messaging.MulticastMessage = {
    tokens: tokens,
    data: data,
    android: {
        ttl: 1000000
    }
};
console.log('Sending\n', msg);
const batchResponse: firebase.messaging.BatchResponse = await firebase.messaging().sendMulticast(msg, DRY_RUN);

In firebase log:

Sending
 { tokens: 
   [ SKIPPED],
  data: 
   { SKIPPED },
  android: { ttl: 1000000 } }

{ Error: TTL must be a non-negative duration in milliseconds
    at FirebaseMessagingError.FirebaseError [as constructor] (/srv/node_modules/firebase-admin/lib/utils/error.js:42:28)
    at FirebaseMessagingError.PrefixedFirebaseError [as constructor] (/srv/node_modules/firebase-admin/lib/utils/error.js:88:28)
    at new FirebaseMessagingError (/srv/node_modules/firebase-admin/lib/utils/error.js:253:16)
    at validateAndroidConfig (/srv/node_modules/firebase-admin/lib/messaging/messaging-types.js:249:19)
    at Object.validateMessage (/srv/node_modules/firebase-admin/lib/messaging/messaging-types.js:49:5)
    at /srv/node_modules/firebase-admin/lib/messaging/messaging.js:260:31
    at Array.map (<anonymous>)
    at Messaging.sendAll (/srv/node_modules/firebase-admin/lib/messaging/messaging.js:259:33)
    at Messaging.sendMulticast (/srv/node_modules/firebase-admin/lib/messaging/messaging.js:308:21)
    at Object.<anonymous> (/srv/lib/controller/fcm.js:79:62)
  errorInfo: 
   { code: 'messaging/invalid-payload',
     message: 'TTL must be a non-negative duration in milliseconds' },
  codePrefix: 'messaging' }

Source code looks totally valid:

        if (!validator.isNumber(config.ttl) || config.ttl < 0) {
            throw new error_1.FirebaseMessagingError(error_1.MessagingClientErrorCode.INVALID_PAYLOAD, 'TTL must be a non-negative duration in milliseconds');
        }

but it rejects proper ttl.
Other configs like collapseKey work well

Ps. there is unnecessary deepCopy in sendAll

Activity

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

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions