Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bec7e51

Browse files
deletemeAkryum
authored andcommittedAug 14, 2024·
fix: (@vue/apollo-option) memory leak in wrapped ssrRender
Fixes #1550 Two leaks were fixed: 1) Prevents repeatedly wrapping `ssrRender` by checking if it's already been wrapped. Added a `__IS_VUE_APOLLO_WRAPPED` boolean to track this. I verified that this was actually happening by throwing an error if it was already wrapped, and I observed the error. 2) `this.$options.ssrRender` doesn't always exist, but this.$apollo does. When the new wrapped `ssrRender` was called, it would throw, which prevented the `destroy.call(this)` line from running. The fix here was to not create a wrapped `ssrRender` if there isn't an original one.
1 parent f236070 commit bec7e51

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed
 

‎packages/vue-apollo-option/src/mixin.js

+3
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,14 @@ export function installMixin (app, provider) {
115115
if (isServer) {
116116
// Patch render function to cleanup apollo
117117
const render = this.$options.ssrRender
118+
if (!render) return
119+
if (render.__IS_VUE_APOLLO_WRAPPED) return
118120
this.$options.ssrRender = (h) => {
119121
const result = render.call(this, h)
120122
destroy.call(this)
121123
return result
122124
}
125+
this.$options.ssrRender.__IS_VUE_APOLLO_WRAPPED = true
123126
}
124127
},
125128

0 commit comments

Comments
 (0)
Please sign in to comment.