Skip to content

Infinite loop when using the render function and the ref parameter. #4743

Closed
@schoonc

Description

@schoonc

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which package are you using?

@sentry/vue

SDK Version

6.18.2

Framework Version

3.2.31

Link to Sentry event

No response

Steps to Reproduce

main.js:

import { createApp, h, ref} from 'vue'
import MyComp from './MyComp.vue'
import * as Sentry from '@sentry/vue'

const myComp = ref()
const app = createApp({
    render() {
        return h(MyComp, { ref: myComp})
    }
})
Sentry.init({
    app,
    dsn: 'some-dsn', // Here you must insert the real "dsn" so that "sentry" will initialize.
    environment: 'some-env',
})
app.mount('#app')

MyComp.vue:

<template>
  <div
    :data-test="test"
  />
</template>

<script>

export default {
  created() {
    /* "setTimeout" and "$forceUpdate" are not related to the problem. It's just a way to cause a component 
        to redraw after a certain amount of time has passed since it was created. */
    setTimeout(() => {
      this.$forceUpdate()
    }, 3000)
  }
}
</script>

After redrawing the component ($forceUpdate), we get the result described below in the actual result section.

The problem disappears if:

  • Do not pass the ref param, like return h(MyComp) instead of return h(MyComp, { ref: myComp})
  • Use SFC (single file component) instead the render function, like const app = createApp(App), App.vue:
<template>
    <my-comp ref="myComp" />
</template>

<script>
import { ref } from 'vue'
import MyComp from './MyComp.vue'
export default {
    components: {
        MyComp
    },
    setup() {
        const myComp = ref()
        return {
            myComp
        }
    }
}
</script>

Expected Result

The application continues to work normally and the console shows this

image

Actual Result

The application goes into an infinite loop, and the console starts to be continually bombarded with this:

image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions