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

Avoid stateful singletons in the SSR #2664

Closed
cmeyertons opened this issue Mar 28, 2019 · 3 comments
Closed

Avoid stateful singletons in the SSR #2664

cmeyertons opened this issue Mar 28, 2019 · 3 comments
Labels
5: Complex P4: Nice to have Priority mark - it's nice to have refactor Code refactoring

Comments

@cmeyertons
Copy link

Current behavior

The same Vuex store instance is shared across requests -- because it contains users specific things like cart

Expected behavior

The vuex store should follow vue's recommendations.
https://ssr.vuejs.org/guide/data.html

@cmeyertons cmeyertons added the bug Bug reports label Mar 28, 2019
@pkarw
Copy link
Collaborator

pkarw commented Mar 30, 2019

Hi, @cmeyertons does it causes any side effects in Your case? I mean:

Please provide us with more info - what exactly do You recommend to change and what kind of issues it causes?

@pkarw
Copy link
Collaborator

pkarw commented Mar 30, 2019

It's probably related to https://ssr.vuejs.org/guide/structure.html#avoid-stateful-singletons, correct?

I think we're safe with the note they posted:

This constraint can be eliminated when using the bundle renderer with { runInNewContext: true }, however, it comes with some significant performance cost because a new vm context needs to be created for each request.

Basically, this is our case. I'm not sure if at this point we can easily refactor state and stores from being singletons as all the core and user modules are created with this style...

Moreover, there are other singletons like route-manager, i18n, event-bus. I think that this is something that requires kind of RFC - to propose general changes to singleton management. The benefit of this refactor would be that we'll be able to switch the runInNewContext: false - potential performance benefit. But not sure if it justifies the refactoring efforts (as the SSR performance is pretty high anyway)?

@pkarw pkarw added refactor Code refactoring P4: Nice to have Priority mark - it's nice to have 5: Complex and removed bug Bug reports labels Mar 30, 2019
@pkarw pkarw changed the title Store is currently shared across requests in SSR Avoid stateful singletons in the SSR Mar 30, 2019
@pkarw
Copy link
Collaborator

pkarw commented Mar 30, 2019

Related: #2522

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5: Complex P4: Nice to have Priority mark - it's nice to have refactor Code refactoring
Projects
None yet
Development

No branches or pull requests

2 participants