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

fix(remix-server-runtime): keep memory storage data across cache clears #2768

Closed

Conversation

sheepsteak
Copy link

@sheepsteak sheepsteak commented Apr 12, 2022

Fixes #1832

This is a repost of #1878 as I'd deleted my fork since I'd done this PR and wasn't able to update the PR anymore.

Using an object stored on global the memory session storage will now keep data when the require cache is purged.

I started adding tests for this but I wasn't sure if they were useful. I can add them if needed. @ryanflorence said this wasn't necessary in original PR.

@MichaelDeBoey MichaelDeBoey changed the title fix(remix-server-runtime): keep memory storage data across cache clears (repost) fix(remix-server-runtime): keep memory storage data across cache clears Apr 12, 2022
@cliffordfajardo
Copy link
Contributor

I think @pcattori 's recent dev server upgrades (#5133) might solve or alleviate this?

@pcattori
Copy link
Contributor

I think @pcattori 's recent dev server upgrades (#5133) might solve or alleviate this?

The new dev server doesn't do any require cache purging, so in-memory stuff sticks around as long as your app server does. That said, for dev mode, some/most app servers will need a way to pick up changes after rebuilds and won't have any fancy server-side HMR to do so. So they'll have to use something like nodemon, which will restart the app server and that will cause a loss of in-memory data.

Definitely an improvement since now this will only happen for rebuilds, not for navigations in the browser between rebuilds. But if you want things to persist across rebuilds, then your app server needs to be managed by some watcher process. You could roll your own with chokidar and then do the require cache purging yourself, which would let you do the global trick to preserve things.

Our current vision is to invest more into the new dev server as we explore things like HMR and JIT compilation by route. Will have a better idea of what "server-side HMR" will mean for us then, which will inform what "keep in-memory stuff around in the server across rebuilds" means or how best to do it.

@brophdawg11
Copy link
Contributor

This should no longer be an issue with the new dev server since we no longer purge the require cache on every request.

@brophdawg11 brophdawg11 closed this Aug 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants