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

limits() requires identity() to pass userinfo #116

Closed
perbrondum opened this issue Apr 2, 2020 · 2 comments
Closed

limits() requires identity() to pass userinfo #116

perbrondum opened this issue Apr 2, 2020 · 2 comments
Assignees
Labels

Comments

@perbrondum
Copy link

DB.salesforce.limits()
.sink(receiveCompletion: { (completion) in
switch completion {
case .finished:
print("Finished limits query")
case let .failure(error) :
print(error)
}
}, receiveValue: { (limitResults: [String:Limit]) in
print(limitResults)
}).store(in: &subscriptions)

alone (with a preceding login, fails w: -999 (missing UserInfo).
2020-04-02 21:18:46.092831+0200 testComb[19823:1760466] Task <86442BB7-2523-4325-AAD4-991B19C63CA5>.<3> finished with error [-999] Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://na84.salesforce.com/services/data/v47.0/limits, NSLocalizedDescription=cancelled, NSErrorFailingURLKey=https://na84.salesforce.com/services/data/v47.0/limits}

But w identity() added to call:,
var subscriptions = Set()
DB.salesforce.identity().sink(receiveCompletion: { (completion) in
switch completion {
case .finished:
print("Logged in")
case let .failure(error) :
print("Failed to login. Error: (error)")
}
}) { identity in
DB.salesforce.limits()
.sink(receiveCompletion: { (completion) in
switch completion {
case .finished:
print("Finished limits query")
case let .failure(error) :
print(error)
}
}, receiveValue: { (limitResults: [String:Limit]) in
print(limitResults)
}).store(in: &subscriptions)
}.store(in: &subscriptions)
}
it works. The old limits() used to leverage the userinfo somehow, or why did it work previously?

@mike4aday mike4aday self-assigned this Apr 2, 2020
@mike4aday
Copy link
Owner

mike4aday commented Apr 2, 2020

Hi @perbrondum. Your code works ok for me, so I'm not able to reproduce your results. See below. I have seen the 'cancelled' error when the user closes the Salesforce-hosted login screen without entering credentials.

import SwiftUI
import Combine
import SwiftlySalesforce

var subscriptions = Set<AnyCancellable>()

struct ContentView: View {
        
    var body: some View {
        Button(action: {
            self.getLimits()
        }) {
            Text("Get Limits")
        }
    }
    
    func getLimits() {
        salesforce.limits().sink(receiveCompletion: { (completion) in
            switch completion {
            case .finished:
                print("Finished limits query")
            case let .failure(error) :
                print(error)
            }
        }, receiveValue: { (limitResults: [String:Limit]) in
            print(limitResults)
        }).store(in: &subscriptions)
    }
}

@perbrondum
Copy link
Author

You're right. And now I can't reproduce it. Closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants