react-native-cookies
react-native-cookies copied to clipboard
Crash when loading session cookie
Platform: iOS
Version: master (f11374745deba9f18f7b8a9bb4b0b2573026f522)
Steps to reproduce:
- Use
fetch()
to hit an endpoint that sets a cookie with no expiry (ie: a session cookie). For exampleset-cookie: foo=bar; Path=/; HttpOnly
- Call
CookieManager.get("https://example.com");
The result is the following stacktrace:
Exception '*** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: expiresDate)' was thrown while invoking get on target RNCookieManagerIOS with params (
"https://app.example.com",
0,
24,
25
)
callstack: (
0 CoreFoundation 0x00000001123e929b __exceptionPreprocess + 331
1 libobjc.A.dylib 0x0000000110641735 objc_exception_throw + 48
2 CoreFoundation 0x00000001123338fc _CFThrowFormattedException + 194
3 CoreFoundation 0x000000011245b3f6 -[__NSDictionaryM setObject:forKey:] + 1046
4 CM_App 0x000000010f9c8380 -[RNCookieManagerIOS get:useWebKit:resolver:rejecter:] + 1584
5 CoreFoundation 0x00000001123f011c __invoking___ + 140
6 CoreFoundation 0x00000001123ed5b5 -[NSInvocation invoke] + 325
7 CoreFoundation 0x00000001123eda06 -[NSInvocation invokeWithTarget:] + 54
8 CM_App 0x000000010f78a25a -[RCTModuleMethod invokeWithBridge:module:arguments:] + 2810
9 CM_App 0x000000010f845f96 _ZN8facebook5reactL11invokeInnerEP9RCTBridgeP13RCTModuleDatajRKN5folly7dynamicE + 790
10 CM_App 0x000000010f845aaf _ZZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEiENK3$_0clEv + 127
11 CM_App 0x000000010f845a29 ___ZN8facebook5react15RCTNativeModule6invokeEjON5folly7dynamicEi_block_invoke + 25
12 libdispatch.dylib 0x000000011526e51d _dispatch_call_block_and_release + 12
13 libdispatch.dylib 0x000000011526f587 _dispatch_client_callout + 8
14 libdispatch.dylib 0x0000000115276058 _dispatch_lane_serial_drain + 720
15 libdispatch.dylib 0x0000000115276b9b _dispatch_lane_invoke + 401
16 libdispatch.dylib 0x000000011527f9c6 _dispatch_workloop_worker_thread + 645
17 libsystem_pthread.dylib 0x000000011564ffd2 _pthread_wqthread + 980
18 libsystem_pthread.dylib 0x000000011564fbe9 start_wqthread + 13
)
Looks like this was introduced in the latest commit. Paging @marcshilling.
Surprising that the expiresDate
would ever be nil, but we should be able to protect against by wrapping that line with a nil check. I'll make a PR.
Even if i set expiration app crashes. do we have a solution for it.
I have forked the repo here: https://github.com/safaiyeh/react-native-cookie-store We can create issues and PRs there to continue the development of the project.