consola icon indicating copy to clipboard operation
consola copied to clipboard

infinite loop protection

Open danielroe opened this issue 9 months ago • 2 comments

Describe the feature

Discovered in https://github.com/nuxt/nuxt/issues/27130, it's possible to create an infinite loop when getters call console.log, which is true for Vue.

Reproduction: https://codepen.io/danielroe/pen/GRaqZOj?editors=1111

import { consola } from "consola"

consola.wrapConsole()

const scaryObject = {
  get value () {
    console.warn('Do not access me!', scaryObject)
  }
}

consola.log(scaryObject)

I wonder if it would be worth trying to add protection against this kind of thing? Maybe JSON.stringify could be called lazily?

Additional information

  • [X] Would you be willing to help implement this feature?

danielroe avatar May 22 '24 15:05 danielroe