Skip to content
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

setUserSession and replaceUserSession Lack Error Handling for Session Storage Failures #334

Open
CorrM opened this issue Feb 2, 2025 · 1 comment
Labels
enhancement New feature or request

Comments

@CorrM
Copy link

CorrM commented Feb 2, 2025

The setUserSession and replaceUserSession methods return a UserSession object that reflects the intended session data, even when the data fails to persist due to storage limits 4096-byte.
This behavior creates a false assumption that the data was saved successfully.

For example:

const newSession = { user: { id: 1 }, token: "large-token-data" };
const result = await setUserSession(event, newSession);
console.log(result); // Outputs `newSession`, even if it wasn't saved

const currentSession = await getUserSession(event);
console.log(currentSession ); // Outputs outdated data

Expected Behavior

If session persistence fails, the methods should throw an error or return a status indicating failure.
The returned UserSession object should only reflect successfully persisted data.

@atinux atinux added the enhancement New feature or request label Feb 4, 2025
@atinux
Copy link
Owner

atinux commented Feb 4, 2025

Indeed, it might be tricky as the data is encoded to know when to throw an error :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants