question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bug: infinite loop async component crashes browser tab

See original GitHub issue

Version

2.6.4

Reproduction link

https://gist.github.com/DominusVilicus/f825d90575fccd6d437b02061c725a91 (code-sandbox doesn’t allow import())

Steps to reproduce

export default {
  render(h){
    return h(import('./comp'))
  }
}

Results in an infinite loop that stops the browser tab from working (chrome). Just need to do vue create app, and create two components, and then use them in the App.vue

export default {
  computed:{
    component(){
      return () => import('./comp')
    }
  },
  render(h){
    return h(this.component)
  }
}

works fine however

comp.vue

<template>
    <pre>Hello World</pre>
</template>

What is expected?

Returning the imported component in h(import('./comp')) should render the async component

What is actually happening?

It’s going in an infinite loop (try put console.log('test') in render()

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:16 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
posvacommented, May 13, 2019

I already told you that we need a variable in my first comment. I would appreciate if you stop spamming, it’s not the first time you do this and it’s not particularly nice.

If you want to, you can instead try to help improve the documentation page for render functions.

What you can do is this:

export default {
  data: () => ({ comp: 'comp' }),
	computed: {
    component(){
		const comp = this.comp
        return () => import('./blocks/' + comp) 
    },
}
    render(h) {
        return h(this.component);
    }
}

and this is the way you do with no modules:

var Comp = () => Promise.resolve({ template: `<div>Comp</div>` })

new Vue({
  el: '#app',
  data: {
    foo: 'bar'
  },
  render: h => h(Comp)
})
1reaction
posvacommented, May 14, 2019

Thanks! Yeah, the doc page for render functions is probably the one that needs the most care among all pages in vuejs docs. It’s also a quite advanced topic so not everybody can contribute to that section, but since you have been experimenting so much with render functions, you should for sure be able to improve that page.

When using a variable like const Component = () => ..., Vue stores a resolved property in it Component.resolved === true (after resolving the promise)

Read more comments on GitHub >

github_iconTop Results From Across the Web

My browser lags when I try a loop function? - Stack Overflow
You are creating an infinite loop here because of for (let j = 0; j < arr[i].length; j *= product);. Here, j is...
Read more >
WPF Hanging in Infinite Rendering Loop - Rick Strahl's Web Log
Ran into a nasty WPF bug this week with Markdown Monster that caused MM to hang during startup in certain scenarios.
Read more >
Why doesn't an infinite loop crash the tab like in JavaScript?
In JavaScript, if you use an infinite loop, it crashes the browser (or, if you use Chrome, the tab). Why doesn't it do...
Read more >
How to solve the React useEffect Hook's infinite loop patterns
Solve the issue of infinite loops when using the useEffect Hook in React to more smoothly utilize the Hook for your app's side...
Read more >
666205 - onblur event is going to infinite loop. - Monorail
We need to know if you will fix this bug or if we need to direct Users to a different browser that doesn't...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found