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(keep-alive): fix keep-alive memory leak #9875

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/core/components/keep-alive.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,13 @@ export default {
vnode.data.keepAlive = true
}
return vnode || (slot && slot[0])
},
updated() {
const { cache } = this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @dejour , just passing by and noticed that you can also destructure the _vnode property in this statemant, avoiding to use this._vnode on the line 127.

Also, the CI points a build failure on the test-cover and lint steps. I think it has nothing to do with your code, since the change it's not on you commit.

for(let key in cache) {
if(cache[key] && cache[key].parent && (cache[key].tag != this._vnode.tag)) {
cache[key].parent = null
}
}
}
}
4 changes: 2 additions & 2 deletions src/server/webpack-plugin/server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { validate, isJS, onEmit } from './util'
import { validate, isJS, onEmit, warn } from './util'

export default class VueSSRServerPlugin {
constructor (options = {}) {
Expand All @@ -23,7 +23,7 @@ export default class VueSSRServerPlugin {
const entryAssets = entryInfo.assets.filter(isJS)

if (entryAssets.length > 1) {
throw new Error(
warn(
`Server-side bundle should have one single entry file. ` +
`Avoid using CommonsChunkPlugin in the server config.`
)
Expand Down