Skip to content

fix(router): prevent memory leaks by removing app references from $router.apps once app destroyed (Fixes #2639) #2640

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

Closed
wants to merge 14 commits into from
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ export default class VueRouter {

// main app already initialized.
if (this.app) {
app.$once('hook:destroyed', () => {
// Clean out app from this.apps array once destroyed
const index = this.apps.indexOf(app)
if (index > -1) this.apps.splice(index, 1)
})
return
}

Expand Down