okta / okta-mobile-swift

okta-mobile-swift
https://github.com/okta/okta-mobile-swift
Apache License 2.0
44 stars 19 forks source link

Crash on CheckedContinuation using `await Credential.refreshIfNeeded()` #170

Closed baksha97 closed 8 months ago

baksha97 commented 8 months ago

Describe the bug?

Multiple concurrent callers to await Credential.refreshIfNeeded() will crash the app.

What is expected to happen?

No crash, all results for the refresh are provided to the callers only once.

What is the actual behavior?

CheckedContinuations fail due to trying to resume to a continuation more than once. image

Reproduction Steps?

Use withThrowingTaskGroup to concurrently call this function. If a refresh is needed, it will be performed and ultimately crash the app.

Additional Information?

No response

SDK Version(s)

All

Build Information

No response

ericwelander commented 8 months ago

We are seeing this issue as well

Code

StackTrace

mikenachbaur-okta commented 8 months ago

Thank you for the feedback, this information is very helpful. I'll look into this, and will update the issue when I know more.

mikenachbaur-okta commented 8 months ago

@baksha97 I've begun working on this, starting with a failing unit test to prove the root cause (All bugs identified in this project are fixed in a TDD-fashion). Once I complete a fix for this, you can see the results here.

mikenachbaur-okta commented 8 months ago

@baksha97 @ericwelander I've merged #173 which addresses this fix. If you want to give it a try please feel free, otherwise I'll be publishing a new release soon, once I complete some other work that is currently in-flight.

I'll close this issue, but feel free to either re-open it, or file new tickets, if you experience other problems.

Also, if you have feedback or encounter bugs, please don't hesitate to file issues, since this is our primary mechanism for collecting developer feedback. We love hearing from our customers, and I personally would like to encourage you to let us know if there's anything we can do to improve these tools.

ericwelander commented 8 months ago

Your fix works for us. Thanks @mikenachbaur-okta!