Replies: 2 comments
-
|
Implementation: |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Creating a session when the user has no intention of logging in is a waste of resources. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
getSessionalways runscreateSessionwhenreadDatacannot find a corresponding entry.Another method that does not run
createSessionin such a case is required when you develop a member-only application and expose its login page to the public.If
createSessionis called too many times (e.g. by DoS attack), the performance of a database can be degraded, especially when you use only RDBMS and do not combine it with KVS NoSQL (e.g. Redis/Valkey).vs
react-router/packages/react-router/lib/server-runtime/sessions.ts
Lines 266 to 270 in 255ac96
The current
getSessionwill perform a wasteful operation even if an user has no merit to receive a session data.vs
As you might notice, it returns just
nullwithout creating new one when no entry.This will not be a breaking change unless you use third party session libraries. However, an author of a third party session library have to modify their library to implement this method. Unfortunately JavaScript/TypeScript cannot provide default method implementations in an interface unlike Java or C#.
Beta Was this translation helpful? Give feedback.
All reactions