Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
4 tasks done
Aziz-AnyDesk opened this issue Nov 17, 2022 · 5 comments · May be fixed by #448
Open
4 tasks done

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

Aziz-AnyDesk opened this issue Nov 17, 2022 · 5 comments · May be fixed by #448
Labels
bounty:$50 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@Aziz-AnyDesk
Copy link

Aziz-AnyDesk commented Nov 17, 2022

New Issue Checklist

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
@parse-github-assistant
Copy link

parse-github-assistant bot commented Nov 17, 2022

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
Copy link
Member

mtrezza commented Nov 17, 2022

Thanks for reporting, could you provide a code example?

@mtrezza mtrezza added the type:bug Impaired feature or lacking behavior that is likely assumed label Nov 17, 2022
@Aziz-AnyDesk
Copy link
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))
                }
            }
        }

@mtrezza mtrezza added the bounty:$50 Bounty applies for fixing this issue (Parse Bounty Program) label Nov 21, 2022
@lsmilek1
Copy link
Contributor

lsmilek1 commented Nov 26, 2023

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

@lsmilek1 lsmilek1 linked a pull request Nov 26, 2023 that will close this issue
2 tasks
@lsmilek1
Copy link
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
Labels
bounty:$50 Bounty applies for fixing this issue (Parse Bounty Program) type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants