reqwest icon indicating copy to clipboard operation
reqwest copied to clipboard

Enable cookies in wasm32

Open jkelleyrtp opened this issue 4 years ago • 11 comments

This PR adds cookie support for wasm targets.

jkelleyrtp avatar Jan 23 '22 17:01 jkelleyrtp

hey I'm interested in this, is there anything I can do to help ?

happysalada avatar Feb 10 '22 03:02 happysalada

I've updated this branch and disabled my toml autoformatter. Hopefully it should clear CI now. Sorry for the wait :) ping @seanmonstar

jkelleyrtp avatar Feb 10 '22 14:02 jkelleyrtp

+1 on this -- hope to see it merged soon.

mitchelldyer01 avatar Mar 12 '22 05:03 mitchelldyer01

@seanmonstar Hey - would love to get your re-review of this since a handful of people have reached out to me about this. Thanks!

jkelleyrtp avatar Jun 13 '22 15:06 jkelleyrtp

Bumping @seanmonstar

jkelleyrtp avatar Jul 11 '22 00:07 jkelleyrtp

Are we certain this is working as expected? It might be something else on my side that is not working correctly, but I have an authentication-related test case that works when I run the program in a non-wasm context, but when I compile to wasm, and run it in a browser, the authentication fails. I haven't dug deep yet to figure out what is going on, but the first thing that jumps out at me is that if the cookie jar isn't working as expected (e.g. cookies returned from request 1 need to be set in request 2), the authentication request fails.

I hope to find some more time this week to verify if it is indeed the cookie jar that is behaving differently between non-wasm and wasm, or if it's something else entirely unrelated to this PR.

edit Actually, I did quickly validate that indeed, the cookie jar is empty on the Wasm target, but not on the native local target. I don't know why that's the case yet, it might still be that the first request actually didn't return any cookies to store in the jar, but I find that highly unlikely, since both targets do the same query to the same endpoint.

edit 2 I just validated that indeed, both on the wasm and non-wasm target, the first response has a set-cookie header, but on the wasm target, that cookie is not added to the cookie jar, while that does happen on the non-wasm target.

JeanMertz avatar Jul 27 '22 08:07 JeanMertz

Any updates? The crates should have all been updated, right?

fee1-dead avatar Nov 02 '22 09:11 fee1-dead

I'm not certain what the status is, actually. It sounds like this needs something from cookie_store? Or from time? Or are all those things fine now? Is the rabbit hole @JeanMertz fell in the same thing?

seanmonstar avatar Nov 15 '22 22:11 seanmonstar

A new feature flag in time was introduced which (I believe) allows it to build w/ the wasm target. cookie_store has been updated to this version of time, and itself exposes a new feature flag wasm-bindgen for enabling the transitive time/wasm-bindgen feature.

Per #1674 , there is some impedance to making the upgrade; it may simply be the updated time dependency needing a higher MSRV that reqwest currently targets? I have followed up in that issue to see if there is a deeper problem.

I personally don't target wasm, so if there are further changes needed to support this in cookie_store that I am missing, users may comment at the existing pfernie/cookie_store#26

pfernie avatar Nov 16 '22 00:11 pfernie