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
After calling withCount on Parse.Query, findAll returns empty array regardless of result #2621
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
Build a query that should have some results
Call withCount(true) on the query
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>[] }
ℹ️ 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.
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
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.
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.
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.
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.
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.
Activity
parse-github-assistant commentedon May 21, 2025
🚀 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.
[-]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[/+]mtrezza commentedon Jan 31, 2026
See discussion in #2854;
withCountshould have never been implemented this way as it creates a type conflict. ThefindAllmethod returns an array of objects, but withwithCount(true)it suddenly returns an object. The solution is to remove thewithCount(true)modifier ofParse.Queryand introduce a new methodfindAllWithCountor similar that can then return an object.mtrezza commentedon Jan 31, 2026
Note that in addition,
withCountis 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.mdarens commentedon Feb 3, 2026
I agree with all of that, but this is still a runtime regression from a previous release/undefined behavior, and
withCountwould still need to spend a major release with deprecation warnings to mitigate further impact.mtrezza commentedon Feb 3, 2026
Implementing
.withCountforfindAllwould 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.
dplewis commentedon Feb 5, 2026
@mtrezza Should we merge #2854 in the meantime?
mtrezza commentedon Feb 5, 2026
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.