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

Sending 2 mutations sequentially, callback doesn't get called on one of them #72

Closed
joelmbell opened this issue Sep 19, 2018 · 6 comments
Labels
question A question about how to use an existing feature

Comments

@joelmbell
Copy link
Contributor

Describe the bug
When you send two mutations, one right after the other, a callback will get called for one of them, but not for the other one.

To Reproduce
Steps to reproduce the behavior:

  1. Send 2 mutations one right after the other
  2. in the resultHandler callback of the perform(mutation:queue:optimisticUpdate:conflictResolutionBlock:resultHandler:) method, print a log statement

Expected behavior
The callback should be called twice, once for each mutation that was sent.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment(please complete the following information):

  • AppSync SDK Version: 2.6.21
  • Dependency Manager: Cocoapods
  • Swift Version : 4.2 (xcode 10)

Device Information (please complete the following information):

  • Device: iPad Pro (9.7-inch)
  • iOS Version: (11.3)

Additional context
If you wait for the first mutation to complete, then call the second everything works as expected. This was working fine in a previous version of app sync, I have not yet identified which version it broke in.

@rohandubal
Copy link
Contributor

Thanks for reporting this @joelmbell

We have a bunch of functional tests where we run about 18 mutations in a for loop which passes: https://github.com/awslabs/aws-mobile-appsync-sdk-ios/blob/master/AWSAppSyncTests/AWSAppSyncTests.swift#L324

Which auth mechanism you are using? (AWS_IAM, API_KEY, UserPools?)

Thanks,
Rohan

@joelmbell
Copy link
Contributor Author

@rohandubal I am using the new AWSCognitoUserPoolsAuthProviderAsync auth mechanism.

I'll continue testing on my end, I should be able to narrow it down further.

@rohandubal
Copy link
Contributor

Thanks for the info @joelmbell

I will try to reproduce on my end as well.

@rohandubal rohandubal added the pending investigation It has been triaged and discussed but the actual work is still pending label Sep 19, 2018
@joelmbell
Copy link
Contributor Author

joelmbell commented Sep 20, 2018

@rohandubal the more I look at this, it seems like its actually an issue the Cognito SDK we're using to fetch the token in func getLatestAuthToken(_ callback: @escaping (String?, Error?) -> Void)

The sdk is never calling its callback the second time a token is requested, so the callback to this function isn't getting called, which is just bubbling up the stack to the actual mutation resultHandler

Given that this isn't an issue with the actual AppSync SDK we can probably close this ticket and I'll handle that case in my application and possibly open a bug on the AWSCognitoAuth iOS proj

@rohandubal
Copy link
Contributor

rohandubal commented Sep 20, 2018

Hello @joelmbell

I tried re-producing on my side but was not able to. It worked as expected on SDK version 2.6.21

I was using the AWSUserPoolsSignIn (AWSCognitoIdentityProvider) SDK and this was the definition of my user pools provider:

class MyCognitoUserPoolsAuthProvider: AWSCognitoUserPoolsAuthProviderAsync {
    
    func getLatestAuthToken(_ callback: @escaping (String?, Error?) -> Void) {
    AWSCognitoUserPoolsSignInProvider.sharedInstance().getUserPool().currentUser()?.getSession().continueWith(block: { (task) -> Any? in
            if let error = task.error {
                callback(nil, error)
            } else if let token = task.result?.idToken?.tokenString {
                callback(token, nil)
            }
            return nil
        })
    }
}

Does your code look similar? I think I might need a some repreo steps or a small sample app from you where I can debug this.

Thanks,
Rohan

@joelmbell
Copy link
Contributor Author

joelmbell commented Sep 21, 2018

@rohandubal closing this, you may have missed my above comment explaining that it was an implementation detail on my end causing this.

In short, the callback in getLatestAuthToken wasn't getting called for the second request. Since that callback wasn't getting called it caused the mutations resultHandler to not be called as well.

Thanks for looking into this, and for responding so quickly!

@frankmuellr frankmuellr added question A question about how to use an existing feature and removed pending investigation It has been triaged and discussed but the actual work is still pending labels Oct 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question about how to use an existing feature
Projects
None yet
Development

No branches or pull requests

3 participants