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(router): prevent memory leaks by removing app references #2706

Merged
merged 15 commits into from Apr 12, 2019

Conversation

2 participants
@posva
Copy link
Member

posva commented Apr 11, 2019

Fix #2639

Hey, @tmorehouse, I refactored the tests and reverted the code added to the if because I couldn't see why we would override the main app. Could you take a look please?

@tmorehouse

This comment has been minimized.

Copy link

tmorehouse commented Apr 11, 2019

I'll take a look here in a bit.

})

// main app previously initialized
// return as we don't need to set up new history listener
if (this.app) {
return
}

This comment has been minimized.

Copy link
@tmorehouse

tmorehouse Apr 11, 2019

With this.app being set to null (if all apps are cleared out), this early return doesn't happen, and the code below it will be executed again.

Will that be an issue? IF so, maybe a flag needs to be set so that the following code is not executed a second time.

This comment has been minimized.

Copy link
@posva

posva Apr 11, 2019

Author Member

but this is called when a router is injected in a created component, it's only executed once per root instance

This comment has been minimized.

Copy link
@tmorehouse

tmorehouse Apr 11, 2019

Doesn't init get called for each app instance, as it is how the apps get added to this.apps array:

  init (app: any /* Vue component instance */) {
    process.env.NODE_ENV !== 'production' && assert(
      install.installed,
      `not installed. Make sure to call \`Vue.use(VueRouter)\` ` +
      `before creating root instance.`
    )

    this.apps.push(app)

This comment has been minimized.

Copy link
@posva

posva Apr 11, 2019

Author Member

yes, but once per root instance

This comment has been minimized.

Copy link
@tmorehouse

tmorehouse Apr 11, 2019

Ah, correct... so it should be good.

@posva posva merged commit 8056105 into dev Apr 12, 2019

5 checks passed

ci/circleci: install Your tests passed on CircleCI!
Details
ci/circleci: lint-flow-types Your tests passed on CircleCI!
Details
ci/circleci: test-e2e Your tests passed on CircleCI!
Details
ci/circleci: test-unit Your tests passed on CircleCI!
Details
deploy/netlify Deploy preview ready!
Details

@posva posva deleted the fix/2639/multiple-apps branch Apr 12, 2019

@posva posva moved this from Long term road (high prio, low complex) to Done in Longterm Apr 15, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.