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

Console exception when reflex updates a page that didn't trigger the update #336

Closed rockhymas closed 3 years ago

rockhymas commented 3 years ago

Bug Report

Describe the bug

Reflex updates that are not triggered by the client they are being sent to, show a console error:

stimulus_reflex.js:387 Uncaught TypeError: Cannot read property 'completedOperations' of undefined
    at HTMLDocument.beforeDOMUpdateHandler (stimulus_reflex.js:387)
    at dispatch (cable_ready.js:83)
    at Object.morph (cable_ready.js:168)
    at Object.perform (cable_ready.js:349)
    at Subscription.received (stimulus_reflex.js:87)
    at action_cable.js:536
    at Array.map (<anonymous>)
    at Subscriptions.notify (action_cable.js:535)
    at Connection.message (action_cable.js:369)

Introduced by https://github.com/hopsoft/stimulus_reflex/pull/299. The promises hash doesn't have an entry for the reflexId passed, but there is not check for null/undefined.

To Reproduce

Use the TodoMVC app in two browser tabs, but with StimulusReflex 3.3.0. Check off a todo. Note that it gets checked off in the other tab. But there is also the console error above.

Expected behavior

No javascript error

Versions

StimulusReflex

External tools

Browser

Schlipak commented 3 years ago

I'm having the same issue, seems related to #335.

leastbad commented 3 years ago

Hi @rockhymas, is this issue fixed by running #335 on your local machine?

It'd be really, really helpful to the project if you were able to help us confirm that our fix for your problem works as intended.

rockhymas commented 3 years ago

I'd love to help out. I'm still fairly new to rails and stimulus reflex. How do I go about using a non-released version of stimulusreflex in my rails app?

leastbad commented 3 years ago

You are in luck! I wrote a new documentation section for you the other day:

https://docs.stimulusreflex.com/setup#running-a-branch-to-test-a-github-pull-request

rockhymas commented 3 years ago

Sweet, that got me unblocked for bit. I now have both the gem and the node package, but the javascript isn't being included in webpack now, so I see this error on page load:

Uncaught Error: Cannot find module 'stimulus_reflex'
    at webpackMissingModule (index.js:1)
    at Module../app/javascript/controllers/index.js (index.js:1)
    at __webpack_require__ (bootstrap:19)
    at Module../app/javascript/packs/application.js (application.js:1)
    at __webpack_require__ (bootstrap:19)
    at bootstrap:83
    at bootstrap:83

Yarn is saying I need to link stimulus_reflex, but when I try to do that it says stimulus_reflex isn't registered. I don't want to turn this issue into my personal tech support, but I'm stumped on this one.

leastbad commented 3 years ago

Can you confirm that you've run yarn install --check-files?

Also, if you're on Discord, this could be easier to solve.

rockhymas commented 3 years ago

Yeah, I've run that, output shows no errors. Will jump on discord.

leastbad commented 3 years ago

Hey @rockhymas, are you sorted on this issue?

rockhymas commented 3 years ago

Yeah, this is great, and I've learned a lot. Thanks again.