-
Notifications
You must be signed in to change notification settings - Fork 1k
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
bug: CapacitorCookieManager (Android) is initialized incorrectly since capacitor version 4.7.3 #6467
Comments
I can confirm this behavior when i need to call an API returning a "set-cookie" header, then this happens: E/Capacitor/Plugin: null
java.lang.NullPointerException
at java.util.Objects.requireNonNull(Objects.java:220)
at uw0.<init>(Unknown Source:3)
at Co.a(Unknown Source:2)
at Co.setCookie(chromium-TrichromeWebViewGoogle6432.apk-stable-463807437:2)
at com.getcapacitor.plugin.CapacitorCookieManager.setCookie(CapacitorCookieManager.java:123)
at com.getcapacitor.plugin.CapacitorCookieManager.put(CapacitorCookieManager.java:176)
at com.android.okhttp.internal.http.HttpEngine.receiveHeaders(HttpEngine.java:891)
at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:625)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:475)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:542)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:106)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:30)
at com.getcapacitor.plugin.util.CapacitorHttpUrlConnection.getResponseCode(CapacitorHttpUrlConnection.java:251)
at com.getcapacitor.plugin.util.HttpRequestHandler.buildResponse(HttpRequestHandler.java:206)
at com.getcapacitor.plugin.util.HttpRequestHandler.request(HttpRequestHandler.java:414)
at com.getcapacitor.plugin.CapacitorHttp$1.run(CapacitorHttp.java:34)
at java.lang.Thread.run(Thread.java:920) |
Still no news on this? I will have to avoid the use of cookies for now until this is solved :( |
This issue may need more information before it can be addressed. In particular, it will need a reliable Code Reproduction that demonstrates the issue. Please see the Contributing Guide for how to create a Code Reproduction. Thanks! |
Looks like a related issue #6479 There is no error when using this property in the capacitor.config.ts
But for production I've to comment out this code. And after that simple POST requests stop working. |
Check out https://github.com/chrste90/capacitor-http-cookie-demo
You can see the following error via logcat:
I wrote already a detailed description why this is happening in my initial post. |
fixed in #6509 |
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
Bug Report
Capacitor Version
Platform(s)
Android
Current Behavior
When the app starts, CapacitorCookieManager is initialized by CapacitorCookies-Plugin. Since
@capacitor/[email protected]
, the localUrl and serverUrl are set in the constructor of CapacitorCookieManagerThe problem is, that the bridge returns null for localUrl at this point, so when
setCookie(getDomainFromCookieString(headerValue), headerValue);
inside the put-Method is called,getDomainFromCookieString(headerValue)
returns null if the cookie doesn't set a domain.Expected Behavior
getDomainFromCookieString(headerValue)
should returnhttp://localhost
instead of null.Code Reproduction
Create simple ionic app with https://github.com/silkimen/cordova-plugin-advanced-http and call a url which sets a cookie similar to:
sessionid=XXX; Expires=Wed Apr 05 2023 10:51:33 GMT+0200 (CEST); SameSite=Lax; Secure; HttpOnly
Other Technical Details
The bug was introduced by this PR: #6448
Additional Context
As a workaround, it's possible to add this to the MainActivity:
It looks like the bridge returns the correct URL if called later.
The text was updated successfully, but these errors were encountered: