formkit: After Update to Vue 3.5.x FormKitSchema cleanup on unmount throws Exception
Reproduction
Describe the bug
Hi,
sorry for passing only the link to the code where the exception is thrown, but you need some more complex application where you toggle between multiple components that includes a FormkitSchema component.
After switching to Vue 3.5 it seems that data on cleanup can be null.
/**
* Perform cleanup operations when the component is unmounted. This should
* remove any memory allocations that were made during the render process.
*/
function cleanUp() {
// Perform cleanup operations
clean(props.schema, props.memoKey, instanceKey)
/* eslint-disable @typescript-eslint/no-non-null-assertion */
if (data.node) data.node.destroy()
data.slots = null!
data = null!
render = null!
/* eslint-enable @typescript-eslint/no-non-null-assertion */
}```
Access data.node throws part throws exception:
Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘node’) at cleanUp (@formkit_vue.js?v=c3cff561:1581:16) at chunk-CXSE3S54.js?v=c3cff561:4847:40 at callWithErrorHandling (chunk-CXSE3S54.js?v=c3cff561:2288:19) at callWithAsyncErrorHandling (chunk-CXSE3S54.js?v=c3cff561:2295:17) at hook.__weh.hook.__weh (chunk-CXSE3S54.js?v=c3cff561:4827:19) at flushPostFlushCbs (chunk-CXSE3S54.js?v=c3cff561:2474:28) at flushJobs (chunk-CXSE3S54.js?v=c3cff561:2516:5)
Changing back to Vue 3.4 fix the issue.
Greetings,
Tom
### Environment
• OS: MacOS 14.6.1
• Browser Chrome
• Version 128.0.6613.120 (Offizieller Build) (arm64)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 2
- Comments: 17 (6 by maintainers)
Commits related to this issue
- fix: #1496 — committed to Abaso007/formkit by justin-schroeder 2 years ago
@jpcarpenter can you checkout 1.6.7? I think this is fixed there now.
Hi Justin, thank you for your fix!
At the moment it fixes my reported problem so i can update to Vue 3.5 (Nuxt 3.13).
Forms with FormKit are a great fun and so useful !
Have a great coding time,
Tom
All seems well now! Thanks for taking the time looking into this!
It looks like it’s something to do with Vue 3.5.6. I changed my Vue version from having
"vue": "^3.5",to"vue": "3.5.5", and the error no longer appears. All my formkit versions are set to 1.6.6 as well.The Vue changelog for 3.5.6 mentions some updates to reactivity and how it relies on a dirty check when computed has deps:
That’s the one thing that stuck out to me based on the context of the error message I was receiving. I could be completely wrong however.
I was encountering this same issue with my Nuxt 3 project. After updating to 1.6.6, I now get a fatal error on page loads:
The Nuxt DevTools gives an additional line in the stack trace on the first line:
Which points here within
./node_modules/@formkit/vue/dist/index.dev.mjsThe weird thing is the error disappears whenever I remove the
helpprop from any/allFormKitinputs on the page…My
package.jsonis as follows:Ok, i just published 1.6.6 that should fix this. Please report if you have further/different 3.5 related issues.