Repository navigation
Description
New Issue Checklist
- I am not disclosing a vulnerability.
- I am not just asking a question.
- I have searched through existing issues.
- I can reproduce the issue with the latest versions of Parse Server and the Parse ObjC SDK.
Issue Description
Since #1708 (2.0.3), +[Parse setServer:] re-initializes Parse with a new ParseManager, which creates its own eventually queue. The previous manager's eventually queue (PFCommandCache, or PFPinningEventuallyQueue with the local datastore) is not paused or terminated. It stays alive because its dispatch source event handler retains it, and it remains a PFReachability listener. Both queues read the same pending commands from the same command cache directory or local datastore. Parse/Parse/Internal/PFCommandCache.h says there should only be one instance, "because multiple instances would be running separate threads trying to read and execute the same commands."
When connectivity returns while saveEventually commands are pending, both queues run them:
- If the previous
ParseManagerwas deallocated, the old queue's weakdataSourceisnil, so-[PFEventuallyQueue _runCommand:withIdentifier:]returnsnil.PFConsistencyAssert(resultTask.completed, ...)in-_didFinishRunningCommand:withIdentifier:resultTask:then raisesNSInternalInconsistencyException("Task should be completed.") on the queue's processing queue, which terminates the app. - If the previous
ParseManageris still alive, both queues send the command. A Cloud Code call beforesetServer:is one thing that keeps it alive, becausePFCloudCodeControllerholds its data source strongly. Without the local datastore, the same request is sent twice. With the local datastore, the old queue sends an empty save (POST classes/<className>with no fields), because only the new queue holds the save's operation set in memory.
Nothing stops the old queue, so this applies until the app is terminated. #913 (2016) reported the same exception with the same stack, before setServer: existed.
Not verified:
- The duplicate goes to the previous server if the previous manager's command runner existed before
setServer:. The old queue sends its duplicate through that runner, which keeps the server URL it was created with. - The old queue also starts a run when it finishes waiting to retry a command after a temporary error, not only when connectivity returns.
- Each further
setServer:call adds another queue.
Found while investigating #1917.
Steps to reproduce
Reproduced in a unit test on master (iOS 26.5 simulator, Xcode 27.1) with mock command runners. Connectivity changes are simulated through PFReachability.
- Initialize Parse, with or without local datastore.
- Call
+[Parse setServer:]with another URL. - Lose connectivity.
- Call
saveEventuallyon a new object. - Regain connectivity.
Losing connectivity before step 2 gives the same result. With local datastore, only that order was tested. To keep the previous manager alive, call a Cloud Code function before step 2.
Actual Outcome
Previous manager deallocated (the case in the test without the Cloud Code call):
- The new queue sends the request and the old queue raises
NSInternalInconsistencyException: Task should be completed., with and without local datastore. - XCTest records the exception as a test failure. When the uncaught exception handler only logs and returns, like the default handler in an app, the test host aborts with
SIGABRT(tested without local datastore).
Previous manager alive:
- Without local datastore, the old and the new command runner both send
POST classes/Yolowith the same body. - With local datastore, the new runner sends
POST classes/Yolowith the object's field, and the old runner sendsPOST classes/Yolowith no fields.
Without setServer:, a pending command is sent once.
Expected Outcome
After setServer:, only one eventually queue processes pending commands. Each command is sent once and no exception is raised.
Environment
Client
- Parse ObjC SDK version:
7.0.0(master)
Server
- Parse Server version: not applicable
- Operating system: not applicable
- Local or remote host: not applicable
Database
- System (MongoDB or Postgres): not applicable
- Database version: not applicable
- Local or remote host: not applicable
Logs
Stack of the crashing thread (com.parse.PFCommandCache.processing queue, EXC_CRASH (SIGABRT)):
+[NSException raise:format:]
-[PFEventuallyQueue _didFinishRunningCommand:withIdentifier:resultTask:]
-[PFCommandCache _didFinishRunningCommand:withIdentifier:resultTask:]
-[PFEventuallyQueue _runCommandsWithRetriesCount:]
-[PFEventuallyQueue _runCommands]
__26-[PFEventuallyQueue start]_block_invoke
With local datastore, the exception is raised through -[PFPinningEventuallyQueue _didFinishRunningCommand:withIdentifier:resultTask:] instead of PFCommandCache.
Activity
parse-github-assistant commentedon Oct 22, 2026
🚀 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.
parseplatformorg commentedon Oct 23, 2026
🎉 This change has been released in version 7.0.2