-
Notifications
You must be signed in to change notification settings - Fork 16
Closed
Description
We are getting several crashes on production from the class AuthorizationMoyaPlugin in GetStream library.
The crash report is:
Crashed: org.alamofire.session.rootQueue.requestQueue
0 CoreFoundation 0x21a34 CFStringGetLength + 60
1 CFNetwork 0x7e00 CFURLRequestSetHTTPRequestBody + 20148
2 CFNetwork 0x5988 CFURLRequestSetHTTPRequestBody + 10812
3 CFNetwork 0x963c CFURLRequestAppendHTTPHeaderFieldValue + 268
4 libswiftFoundation.dylib 0x2eb558 URLRequest.addValue(_:forHTTPHeaderField:) + 304
5 GetStream 0x137a8 AuthorizationMoyaPlugin.prepare(_:target:) + 26 (AuthorizationMoyaPlugin.swift:26)
6 GetStream 0x13820 protocol witness for PluginType.prepare(_:target:) in conformance AuthorizationMoyaPlugin + 20 (<compiler-generated>:20)
7 Moya 0x11134 closure #1 in MoyaProvider.interceptor(target:) + 169 (MoyaProvider+Internal.swift:169)
8 Moya 0xb630 specialized MoyaRequestInterceptor.adapt(_:for:completion:) + 133 (Moya+Alamofire.swift:133)
9 Moya 0xb1dc protocol witness for RequestAdapter.adapt(_:for:completion:) in conformance MoyaRequestInterceptor + 28 (<compiler-generated>:28)
10 Alamofire 0xafb1c Session.performSetupOperations(for:convertible:) + 1988 (<compiler-generated>:1988)
11 Alamofire 0xae950 closure #1 in closure #1 in Session.perform(_:) + 1010 (Session.swift:1010)
12 Alamofire 0x372b8 thunk for @escaping @callee_guaranteed () -> () + 20 (<compiler-generated>:20)
13 libdispatch.dylib 0x1c04 _dispatch_call_block_and_release + 32
14 libdispatch.dylib 0x3950 _dispatch_client_callout + 20
15 libdispatch.dylib 0xb0ac _dispatch_lane_serial_drain + 664
16 libdispatch.dylib 0xbc44 _dispatch_lane_invoke + 444
17 libdispatch.dylib 0xaf84 _dispatch_lane_serial_drain + 368
18 libdispatch.dylib 0xbc10 _dispatch_lane_invoke + 392
19 libdispatch.dylib 0x16318 _dispatch_workloop_worker_thread + 656
20 libsystem_pthread.dylib 0x11b0 _pthread_wqthread + 288
21 libsystem_pthread.dylib 0xf50 start_wqthread + 8
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:
func prepare(_ request: URLRequest, target: TargetType) -> URLRequest {
let token = self.token
if token.isEmpty {
return request
}
var request = request
request.addValue("jwt", forHTTPHeaderField: "Stream-Auth-Type")
request.addValue(token, forHTTPHeaderField: "Authorization")
return request
}
Related info
- GetStream (2.2.4):
- GetStream/Core (= 2.2.4)
- GetStream/Faye (= 2.2.4)
- GetStream/Core (2.2.4):
- GetStream/Faye (2.2.4):
Xcode 13.0
Crashes detected in several devices, including iOS15 and iOS14
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels