stimulusreflex / stimulus_reflex

Build reactive applications with the Rails tooling you already know and love.
https://docs.stimulusreflex.com
MIT License
2.28k stars 172 forks source link

"Uncaught (in promise)" error after failed declarative reflex #170

Closed leastbad closed 4 years ago

leastbad commented 4 years ago

Bug Report

When a declared (eg. data-reflex) reflex fails on the server, the promise rejection generates an error.

To Reproduce

Vanilla Rails 6 app w/SR + scaffolded resource. Declare a reflex that goes to a non-existant action in a reflex class eg:

<h1 data-reflex="click->ApplicationReflex#meat">MEAT</h1>

This generates the following log output:

StimulusReflex::Channel Failed to invoke ApplicationReflex#meat! http://localhost:3000/posts/new undefined method `meat' for class `ApplicationReflex' /home/leastbad/.rvm/gems/ruby-2.6.5/gems/stimulus_reflex-3.1.3/lib/stimulus_reflex/channel.rb:53:in `method'

and the following error in the console:

uncaught

Expected behavior

No errors in the console.

Versions

StimulusReflex

External tools

Browser

leastbad commented 4 years ago

@hopsoft I'm trying to work through this https://discord.com/channels/629472241427415060/708177464894947362/710151681689518130

The question really is: assuming unnecessary scary errors are lazy APIs, should we / could we make an effort to determine whether to return a promise or not based on how stimulate() was called (via declared reflex or explicit JS)

leastbad commented 4 years ago

Closed by #193