Deprecate and replace createWorkersKVSessionStorage
#10151
Replies: 3 comments 2 replies
-
You could replace it with D1 backed session storage, but there's no helper for that, you will need to use createSessionStorage to build one yourself. |
Beta Was this translation helpful? Give feedback.
-
'Had thought through this consequence and accepted it since sessions are localized - reads and writes to a single session are through one POP (unless a user jumps via VPN or other). Would KV work under this constraint or still result in eventual consistency? |
Beta Was this translation helpful? Give feedback.
-
Yeah I steered well away from KV backed session storage for this reason. I'm surprised Remix are still shipping it tbh.
One thing to bear in mind if anybody is moving from DB-backed to cookie session storage is the data will be exposed to the client as it's not encrypted (merely signed), so the security risks are significantly different -- you prob wouldn't want to store long-lived We ended up implementing an iron cookie for Remix which offers encryption similar to iron-session but it does increase the size of the data significantly. Would be great to see |
Beta Was this translation helpful? Give feedback.
-
createWorkersKVSessionStorage
is dangerous because Workers KV is only eventually consistent. I think it should be deprecated, or at least very clearly marked as unsuitable for production use.I learned this the very hard way today after a total authentication outage which turned out to be a result of a KV slowdown. Writes were taking several seconds to show up in subsequent reads, so there was a state mismatch on every single OAuth2 login callback.
We've worked around it for now by switching to cookie session storage, but that's not really a long term solution. I don't have an opinion yet on what to replace it with, I just wanted to get this reported ASAP.
Beta Was this translation helpful? Give feedback.
All reactions