GetStream / stream-swift

Swift client for Stream API
https://getstream.io
BSD 3-Clause "New" or "Revised" License
35 stars 26 forks source link

Update AuthorizationMoyaPlugin.swift #36

Closed ceciliadev closed 2 years ago

ceciliadev commented 2 years ago

fix crash due to token race condition in AuthorizationMoyaPlugin

Submit a pull request

CLA

Description of the pull request

Following the suggestion to create a PR related to this bug issue submitted by @angelolloqui

We are getting several crashes on production from the class AuthorizationMoyaPlugin in GetStream library. The crash report is: [...] It seems the token variable is not correct when setting this value in the request. I am checking the code and I do not see any wrong thing, except that token is an instance variable that might change and produce a race condition between the if token.isEmpty and the actual usage. Not sure if it helps, but maybe rewriting it to this would protect it: [...]

angelolloqui commented 2 years ago

Please @b-onc can you give a bit of ❤️ to this one?