Flag up non-existing controller references

It’s easy to make a typo in a data-controller reference. And it’s hard to debug it: the functionality simply stops working without no indication of what the problem is.

It would be nice if data-controller references that resolve to nothing, threw an error. Or, perhaps, if there were an option to turn that check on.

Thanks,
Artem

1 Like

I was hit by the same thing today. I think this is a bug. I opened an issue for this at Handle error when controller not found · Issue #712 · hotwired/stimulus · GitHub.

Lets assume I am referencing a controller at data-controller="does-not-exist", which does not exist.
This can happen due to a typo - or because the controller has not been loaded for some reason (e.g. not in the load path, caching issue etc.)

When I see it correctly, this would never get raised. Not as an exception. Not even when the debug mode is enabled.

What is the rigtht approach to get this noticable? I would prefer if I can see it in my console when debug mode is enabled and when this will be handled by Application#handleError.