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

Use file store for session data #1658

Merged
merged 4 commits into from
Oct 10, 2022
Merged

Use file store for session data #1658

merged 4 commits into from
Oct 10, 2022

Conversation

lfdebrux
Copy link
Member

@lfdebrux lfdebrux commented Oct 5, 2022

This PR removes support for the cookie session data store, and uses a file store instead.

When running the kit locally this will preserve session data between restarts, which is useful for users when they are editing their routes file a lot.

When running online with a PaaS such as Heroku we expect for most service providers the storage will be ephemeral, so we can't guarantee the data will be preserved there. There is a possibility that some service providers might make it difficult for the kit to save data to disk, but since we're doing this already with compiled CSS files and the like I think if that becomes an issue session storage will not be the only blocker.

File storage is potentially slower and more resource-intensive than memory storage, however for local development the advantage of preserving data is very clear, and even in production using this library has a it has a few advantages over the default memory store - the main one being that it makes sure to prune expired sessions, so is less liable to 'leak' memory over time. Using the same store locally and when hosted also seems preferable in terms of reducing complexity and failure modes.

The file store also has a major advantage over the previous solution, cookie storage, or any other client store, in that it is not bound by browser or HTTP restrictions, so prototypes can store a lot more data. For this reason this PR also removes the cookie store support, as we have no evidence of it being used, and we know that for some users the cookie store storage limits are considered harmful. The use case that the cookie store was added for, preserving session data during restarts while doing local development, is covered better by the file store, and we shouldn't keep code no one is using.

This PR resolves #1655.

@lfdebrux lfdebrux closed this Oct 6, 2022
@lfdebrux lfdebrux reopened this Oct 6, 2022
It looks like these helpers were added by @BenSurgisonGDS in commit
46a1a50, but never wired into place. Let's use them, they look great!
@lfdebrux lfdebrux changed the title Use sessionUtils to configure session data store middleware Use file store for session data Oct 6, 2022
When running the kit locally this will preserve session data between
restarts. When running online with a PaaS such as Heroku we expect for
most service providers the storage will be ephemeral, so we can't
guarangee the data will be preserved there.
@lfdebrux lfdebrux marked this pull request as ready for review October 6, 2022 13:09
@lfdebrux lfdebrux linked an issue Oct 6, 2022 that may be closed by this pull request
3 tasks
Copy link
Contributor

@BenSurgisonGDS BenSurgisonGDS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@lfdebrux lfdebrux merged commit bf4474e into v13 Oct 10, 2022
@lfdebrux lfdebrux deleted the ldeb-session-store branch October 10, 2022 09:20
This was referenced Nov 17, 2022
lfdebrux added a commit that referenced this pull request Nov 18, 2022
Remove #1648 from changelog we backed out those changes in #1658.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate session data storage
2 participants