Skip to content

[bug] beforeDestroy lifecycle methods not called on Vue components (memory leak) #907

Closed
@trusktr

Description

@trusktr

Bug Report

I noticed that when using Vue in a script tag, the components are not cleaned up when navigating away from the page.

Steps to reproduce

Put the following in your markdown file:

<div id="example"></div>
<script type="application/javascript">
  new Vue({
    el: '#example',
    template: `
      <div>blah blah</div>
    `,
    beforeDestroy() {
      debugger . // it never pauses here.
      console.log('DESTROY VUE COMPONENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!')
    },
  })

  console.log('test') // NOTE, this returns undefined.
</script>

What is current behaviour

When you switch pages, you will not see DESTROY VUE COMPONENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! in the console.

What is the expected behaviour

We should see DESTROY VUE COMPONENT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! in the console.

beforeDestroy is not being fired, which means that components that need to clean up aren't cleaning up, and therefore will cause memory leaks.

Other relevant information

Note, I disabled executeScript from executing my script a second time, due to #906. I noticed there that it attempts to catch the return value of the script. That's definitely not foolproof.

  • Bug does still occur when all/other plugins are disabled?

  • Docsify version: 4.9.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions