Skip to content

Parse.Push.send() ignores ParseQuery limit and skip parameters #1956

Open
@shlusiak

Description

@shlusiak

New Issue Checklist

Issue Description

In our attempts to deal with rate limiting when sending push notifications to a huge installation base, we tried to batch them and only send 5000 push noticiations per 30 seconds. We tried to set limit and skip for a ParseQuery to loop until all items are iterated on. This is our code:

async function batchPush(query: Parse.Query<Parse.Installation>, data: PushData, total: number) {
  let skip = 0;
  const batchSize = 5_000;
  const interBatchDelay = 30 * 1_000; // 30,000ms = 30 Seconds

  query.limit(batchSize);
  query.skip(skip);

  while (skip < total) {
    await Parse.Push.send({ where: query, data }, { useMasterKey: true });
    await sleep(interBatchDelay);
    skip = skip + batchSize;
    query.skip(skip);
  }
  return true;
}

But as it turns out, the limit and skip values from the ParseQuery are ignored by Parse.Push.send, sending it to all installations instead:

Parse-SDK-JS/src/Push.js

Lines 54 to 57 in 98674f0

export function send(data: PushData, options?: FullOptions = {}): Promise {
if (data.where && data.where instanceof ParseQuery) {
data.where = data.where.toJSON().where;
}

It seems it will only look at the where part of the ParseQuery, ignoring the limit and skip. As a result our loop still sends notifications to the entire installation base.

Steps to reproduce

Set limit and skip of a ParseQuery used in Parse.Push.send

Actual Outcome

limit and skip are ignored

Expected Outcome

Only the specified range should receive push notifications.

Environment

Client

  • Parse JS SDK version: 4.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:featureNew feature or improvement of existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions