Skip to content

After calling withCount on Parse.Query, findAll returns empty array regardless of result #2621

Open

Description

@mdarens

New Issue Checklist

Issue Description

When building a query dynamically, if withCount is called before findAll, the request payload sent over REST just looks like that for a regular find query with count— batchSize is not sent as the limit, and no subsequent requests are sent with an object id cursor. Even if results come back, the SDK returns an empty array to the caller and fails silently. This appears to have regressed in the SDK at some point between 4.1.0 (where this was working previously) and 6.1.1 (where I encountered it), but I haven't pinpointed it further than that. Obviously if one is using findAll they can just use the size of the result to get the count, but this is definitely unexpected behavior. My workaround in app code is to call withCount conditionally exclusive to the condition for calling findAll.

Steps to reproduce

  1. Build a query that should have some results
  2. Call withCount(true) on the query
  3. Await findAll on the query

Actual Outcome

The result is an empty array despite the results appearing in the network tab

Expected Outcome

findAll ignores withCount when building the query, but shapes the result to match the expectation of calling with count: { count: number; results: Parse.Object<T>[] }

Environment

Chrome 136.0.7103.114 (Official Build) (arm64)
Parse JS SDK: 6.1.1
Parse Server: 8.2.0
Node: LTS 20.19.2

Server

  • Parse Server version: 8.2.0
  • Operating system: alpine Linux
  • Local or remote host (AWS, Azure, Google Cloud, Heroku, Digital Ocean, etc): Google Cloud

Database

  • System (MongoDB or Postgres): MongoDB
  • Database version: 6.0.23
  • Local or remote host (MongoDB Atlas, mLab, AWS, Azure, Google Cloud, etc): Google Cloud

Client

  • Parse JS SDK version: 6.1.1

Logs

Activity

  1. parse-github-assistant commented on May 21, 2025

    @parse-github-assistant

    🚀 Thanks for opening this issue!

    ℹ️ You can help us to fix this issue faster by opening a pull request with a failing test. See our Contribution Guide for how to make a pull request, or read our New Contributor's Guide if this is your first time contributing.

  2. changed the title [-]After calling `withCount` on `Parse.Query`, of `findAll` returns empty array regardless of result[/-] [+]After calling `withCount` on `Parse.Query`, `findAll` returns empty array regardless of result[/+] on May 22, 2025
  3. added
    type:bugImpaired feature or lacking behavior that is likely assumed
    on May 24, 2025
  4. mtrezza commented on Jan 31, 2026

    @mtrezza
    Member

    See discussion in #2854; withCount should have never been implemented this way as it creates a type conflict. The findAll method returns an array of objects, but with withCount(true) it suddenly returns an object. The solution is to remove the withCount(true) modifier of Parse.Query and introduce a new method findAllWithCount or similar that can then return an object.

  5. mtrezza commented on Jan 31, 2026

    @mtrezza
    Member

    Note that in addition, withCount is currently inefficiently implemented on the Parse Server side; causing 2 distinct queries to the DB, instead of using an aggregation. So currently the most efficient way to paginate through objects and get a total doc count is to use an aggregation.

  6. mdarens commented on Feb 3, 2026

    @mdarens
    Author

    I agree with all of that, but this is still a runtime regression from a previous release/undefined behavior, and withCount would still need to spend a major release with deprecation warnings to mitigate further impact.

  7. mtrezza commented on Feb 3, 2026

    @mtrezza
    Member

    Implementing .withCount for findAll would require code changes that create type ambiguity. This wasn't an issue before, but now that we've moved to TypeScript, the issue becomes obvious. Since this is not a server issue but purely a SDK issue, there is no need to phase it out, as the change can be made immediately for new client releases. The solution is remove the method, release a new major SDK version, and for the developer to switch to a CloudFunction or the Parse Server REST API.

    Another issue is that Parse Server Cloud Code depends on the JS SDK, so we can't remove the API as we wouldn't be able to merge that into Parse Server. Hmm... maybe we need to merge #2854 after all.

  8. dplewis commented on Feb 5, 2026

    @dplewis
    Member

    @mtrezza Should we merge #2854 in the meantime?

  9. mtrezza commented on Feb 5, 2026

    @mtrezza
    Member

    Let's merge it and then remove the .withCount method in a few months in Parse Server 10. Double the work, but maybe better than keeping the bug for now.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions