Skip to content

Parse.User save not dispatching back to callback queue when result is success #431

Open
@Aziz-AnyDesk

Description

@Aziz-AnyDesk

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 Swift SDK.

Issue Description

Parse.User save method is not dispatching the result back to callback queue if the result is success. It is dispatching back to callback queue only if it fails. Looking at source code, I suspect this might be the case for all Parse Objects.

Steps to reproduce

Call save method of existing Parse.User

Actual Outcome

The result is not dispatched back to the callback queue when the save succeeds.

Expected Outcome

The result should be dispatched back to the callback queue when save succeeds.

Environment

Plain iOS app with Parse client version 4.14.2.

Client

  • Parse Swift SDK version: 4.14.2
  • Xcode version: 14.1
  • Operating system (iOS, macOS, watchOS, etc.): macOS Ventura
  • Operating system version: Ventura 13.0.1

Activity

parse-github-assistant

parse-github-assistant commented on Nov 17, 2022

@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.
mtrezza

mtrezza commented on Nov 17, 2022

@mtrezza
Member

Thanks for reporting, could you provide a code example?

added
type:bugImpaired feature or lacking behavior that is likely assumed
on Nov 17, 2022
Aziz-AnyDesk

Aziz-AnyDesk commented on Nov 18, 2022

@Aziz-AnyDesk
Author

Here is an example:

let currentUser = Parse.User.current
let userToUpdate = user.set(\.customKey, to: 5)
userToUpdate.save { result in
       print(Thread.isMainThread) 
       // This prints false even though save is called from main thread and default callback queue is set to main thread.
}

I believe this piece of code inside save function of ParseSwift SDK is responsible for this issue:

Task {
            do {
                let object = try await command(method: method,
                                               ignoringCustomObjectIdConfig: ignoringCustomObjectIdConfig,
                                               options: options,
                                               callbackQueue: callbackQueue)
                completion(.success(object)) // This is wrong. This line should be wrapped inside callbackQueue.async
            } catch {
                let defaultError = ParseError(code: .unknownError,
                                              message: error.localizedDescription)
                let parseError = error as? ParseError ?? defaultError
                callbackQueue.async {
                    completion(.failure(parseError))
                }
            }
        }
added
bounty:$50Bounty applies for fixing this issue (Parse Bounty Program)
on Nov 21, 2022
lsmilek1

lsmilek1 commented on Nov 26, 2023

@lsmilek1
Contributor

I can confirm that this affects all ParseObjects. @mtrezza , I created Pull Request, could you please have a look at it? #448

linked a pull request that will close this issue on Nov 26, 2023
lsmilek1

lsmilek1 commented on Feb 13, 2024

@lsmilek1
Contributor

@mtrezza, who could check and eventually release the #448? I gave learned a bit more and hopefully figured it out. Thank you!

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

    bounty:$50Bounty applies for fixing this issue (Parse Bounty Program)type:bugImpaired feature or lacking behavior that is likely assumed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @mtrezza@lsmilek1@Aziz-AnyDesk

      Issue actions

        Parse.User save not dispatching back to callback queue when result is success · Issue #431 · parse-community/Parse-Swift