hotwired / stimulus-rails

Use Stimulus in your Ruby on Rails app

Home Page:https://stimulus.hotwired.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Log Import Failures at a Higher Log Level Than Debug

chadrschroeder opened this issue · comments

If I'm using importmap-rails and make a mistake while importing a module into a Stimulus controller, the error message related to this is logged with console.debug here:

// app/assets/javascripts/stimulus-loading.js
import(path)
  .then(module => registerController(name, module, application))
  .catch(error => console.debug(`Failed to register controller: ${name} (${path})`, error))

This will only appear if the browser's JavaScript console is in Verbose or Debug mode. By default, this is off in Chrome. When I was using Stimulus with Webpacker, this kind of error was logged at a higher level. Would it be possible to make these critical errors more visible so they could be spotted easily in any environment?

Other areas in Stimulus use console.log for errors. And code in importmap-rails and turbo-rails use console.warn and console.error for displaying caught exceptions. I think console.error would make sense when a controller completely fails to load.

See this comment for more on how to recreate the problem.