Subscribe on changes!

warnHandler not invoked prior to `app.mount()` due to null `stack` / `instance` reference

avatar
Jan 20th 2022

Version

3.2.27

Reproduction link

jsfiddle.net

Steps to reproduce

  • Note logs in console
  • Note comment on line 11 of JS source

What is expected?

warnHandler be invoked for all warnings, even if app is not yet instanced / mounted.

What is actually happening?

warnHandler is skipped and internal warn handler runs.

Potentially related:

#4479

avatar
Jan 20th 2022

The warnHandler is meant to handle warnings from things happening in components, i.e. during render. it's not meant to catch this kind of warning, really. That's why it receives a vm as the second argument.

avatar
Jan 20th 2022

That makes sense, but I'd think that internal warn's shouldn't be issued outside the scope of a component if that's the case. Having a warnHandler override that doesn't override all uses of warn seems unintuitive.

Would it be possible for warnHandler to be invoked with alternative arguments in the case that a component instance is not yet spun up?

avatar
Oct 17th 2022

This also happens when rendering a component server-side using @vue/server-renderer. How can we get the warnings during SSR to fail the request or at least print them in the browser?

avatar
Jul 12th 2023

@LinusBorg The default warn handler does not follow that pattern tho, it allows for instance vue-router to create copious amounts of warnings outside of the mount cycle without any way to ignore them.