Skip to content

Provide way to destroy app in SSR #9463

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

Open
ronald-d-rogers opened this issue Feb 8, 2019 · 0 comments · May be fixed by #9479
Open

Provide way to destroy app in SSR #9463

ronald-d-rogers opened this issue Feb 8, 2019 · 0 comments · May be fixed by #9479

Comments

@ronald-d-rogers
Copy link

ronald-d-rogers commented Feb 8, 2019

What problem does this feature solve?

This issue is related to: vuejs/vue-router#2606
Providing a way to destroy the app or mark the SSR request as complete (maybe on $ssrContext) is a potential fix to this problem, though maybe not the best one.

To recap:
A memory leak happens when the router-view is programmed to appear conditionally, and the component matching the view has a beforeRouteEnter guard and a callback is passed to it's next(...) method (e.g. next(vm => {})).

This will cause vue-router to poll every 16ms until the router-view materializes.

In a typical SSR application an instance of the app is created per request, which means the router-view will never appear, causing infinitely recursing poll methods.

What does the proposed API look like?

A potential fix to this would be to detect when the app is destroyed in vue-router's poll method, and allow the user to destroy the app that they created in entry-server.js.

A simplified example:

export default context => {
  return new Promise((resolve, reject) => {
    const { app, router } = createApp(context)

    const { url } = context

    router.push(url)

    router.onReady(() => {
      resolve(app)
    }, reject)
  }).then(destroyApp)
}
@vuejs vuejs deleted a comment from xtreomass12 Feb 11, 2019
ronald-d-rogers added a commit to ronald-d-rogers/vue that referenced this issue Feb 12, 2019
@ronald-d-rogers ronald-d-rogers linked a pull request Feb 12, 2019 that will close this issue
13 tasks
ronald-d-rogers added a commit to ronald-d-rogers/vue that referenced this issue Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants