Skip to content

Commit ebe8572

Browse files
authored
fix(fcm): Increased FCM batch request limit to 500 (#696)
* Increased FCM batch request limit to 500 * Updated documentation
1 parent 867a05f commit ebe8572

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

src/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5000,7 +5000,7 @@ declare namespace admin.messaging {
50005000
* return value.
50015001
*
50025002
* @param messages A non-empty array
5003-
* containing up to 100 messages.
5003+
* containing up to 500 messages.
50045004
* @param dryRun Whether to send the messages in the dry-run
50055005
* (validation only) mode.
50065006
* @return A Promise fulfilled with an object representing the result of the
@@ -5023,7 +5023,7 @@ declare namespace admin.messaging {
50235023
* a `BatchResponse` return value.
50245024
*
50255025
* @param message A multicast message
5026-
* containing up to 100 tokens.
5026+
* containing up to 500 tokens.
50275027
* @param dryRun Whether to send the message in the dry-run
50285028
* (validation only) mode.
50295029
* @return A Promise fulfilled with an object representing the result of the

src/messaging/messaging.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const FCM_TOPIC_MANAGEMENT_ADD_PATH = '/iid/v1:batchAdd';
4040
const FCM_TOPIC_MANAGEMENT_REMOVE_PATH = '/iid/v1:batchRemove';
4141

4242
// Maximum messages that can be included in a batch request.
43-
const FCM_MAX_BATCH_SIZE = 100;
43+
const FCM_MAX_BATCH_SIZE = 500;
4444

4545
// Key renames for the messaging notification payload object.
4646
const CAMELCASED_NOTIFICATION_PAYLOAD_KEYS_MAP = {
@@ -283,7 +283,7 @@ export class Messaging implements FirebaseServiceInterface {
283283
* An error from this method indicates a total failure -- i.e. none of the messages in the
284284
* list could be sent. Partial failures are indicated by a BatchResponse return value.
285285
*
286-
* @param {Message[]} messages A non-empty array containing up to 100 messages.
286+
* @param {Message[]} messages A non-empty array containing up to 500 messages.
287287
* @param {boolean=} dryRun Whether to send the message in the dry-run (validation only) mode.
288288
*
289289
* @return {Promise<BatchResponse>} A Promise fulfilled with an object representing the result
@@ -335,7 +335,7 @@ export class Messaging implements FirebaseServiceInterface {
335335
* indicates a total failure -- i.e. none of the tokens in the list could be sent to. Partial
336336
* failures are indicated by a BatchResponse return value.
337337
*
338-
* @param {MulticastMessage} message A multicast message containing up to 100 tokens.
338+
* @param {MulticastMessage} message A multicast message containing up to 500 tokens.
339339
* @param {boolean=} dryRun Whether to send the message in the dry-run (validation only) mode.
340340
*
341341
* @return {Promise<BatchResponse>} A Promise fulfilled with an object representing the result

test/integration/messaging.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ describe('admin.messaging', () => {
122122
});
123123
});
124124

125-
it('sendAll(100)', () => {
125+
it('sendAll(500)', () => {
126126
const messages: admin.messaging.Message[] = [];
127-
for (let i = 0; i < 100; i++) {
127+
for (let i = 0; i < 500; i++) {
128128
messages.push({topic: `foo-bar-${i % 10}`});
129129
}
130130
return admin.messaging().sendAll(messages, true)

test/unit/messaging/messaging.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -587,14 +587,14 @@ describe('Messaging', () => {
587587
}).to.throw('messages must be a non-empty array');
588588
});
589589

590-
it('should throw when called with more than 100 messages', () => {
590+
it('should throw when called with more than 500 messages', () => {
591591
const messages: Message[] = [];
592-
for (let i = 0; i < 101; i++) {
592+
for (let i = 0; i < 501; i++) {
593593
messages.push(validMessage);
594594
}
595595
expect(() => {
596596
messaging.sendAll(messages);
597-
}).to.throw('messages list must not contain more than 100 items');
597+
}).to.throw('messages list must not contain more than 500 items');
598598
});
599599

600600
it('should throw when a message is invalid', () => {
@@ -847,14 +847,14 @@ describe('Messaging', () => {
847847
}).to.throw('tokens must be a non-empty array');
848848
});
849849

850-
it('should throw when called with more than 100 messages', () => {
850+
it('should throw when called with more than 500 messages', () => {
851851
const tokens: string[] = [];
852-
for (let i = 0; i < 101; i++) {
852+
for (let i = 0; i < 501; i++) {
853853
tokens.push(`token${i}`);
854854
}
855855
expect(() => {
856856
messaging.sendMulticast({tokens});
857-
}).to.throw('tokens list must not contain more than 100 items');
857+
}).to.throw('tokens list must not contain more than 500 items');
858858
});
859859

860860
const invalidDryRun = [null, NaN, 0, 1, '', 'a', [], [1, 'a'], {}, { a: 1 }, _.noop];

0 commit comments

Comments
 (0)