Comments (7)
@julianrubisch good idea, thanks!
I've been playing around with this and will hopefully submit a PR tonight or tomorrow morning CET (rm -rf /
and all, @leastbad 😸 )
from cable_ready.
I like these ideas, but I admit that I'm similarly stumped in terms of their implementation.
Is this something we could do on an environment basis? When are you running seeds? eg. is this a testing thing?
I do have an idea how we could implement @andrewerlanger's idea that will likely make us all 🤮 a little bit, but here goes: there's only 4 actual instances of ActionCable.server.broadcast
in updatable.rb
and model_updatable_callbacks.rb
... what if we:
- Create a single method that calls
ActionCable.server.broadcast
and convert those four instances to use it. - Wrap the above
broadcast
call in a conditional check for a@@global
Boolean variable that gets set by - A new
CableReady::Updateable.without_updates
method that would look sort of like:
def without_updates do
@@what_could_go_wrong = true
yield
@@what_could_go_wrong = false
end
It's putting perfume on a pig, but I think it would allow us to brute force this without boiling the ocean.
from cable_ready.
@leastbad that sounds and looks like a solid idea – I'd be happy to give it a try early next week and see what 🤮 -potential I can reach.
One concern that springs to mind is the class variable being (re-)set before its time, like if someone were to try and pass an async task in the block, e.g.
cable_ready.without_updates { RaceConditionJob.perform_later }
What do you think?
P.S:
Is this something we could do on an environment basis? When are you running seeds? eg. is this a testing thing?
I'm afraid this is a bit of an env-agnostic issue. We run seeds in development, data migrations in development, staging and production. We use MockRedis
in our test environment anyway so haven't had any issues related to updates_for
there (without the mock server we would).
from cable_ready.
I think that if they run an async job inside a helper that is literally an escape hatch for the developer of a site to very intentionally run processes that shouldn't flood the UI with updates... then they deserve what's coming to them.
It's all about the intentionality. We could embed <%= `rm -rf /` %>
in our view templates, but we have to give developers enough guidance that they don't want to do that to themselves.
As I often say to Julian, it all comes down to good documentation, IMO!
I can't wait to see what you come up with. 😺
from cable_ready.
Maybe we could take inspiration from how https://api.rubyonrails.org/classes/ActiveRecord/NoTouching/ClassMethods.html is implemented
from cable_ready.
I haven't used this feature yet, but it's an inspiring one so I've been digging in.
What if there were a configuration governing how Redis::CannotConnectError
errors are handled during enable_updates
broadcasts?
config.enable_updates_connection_errors = :log
where the available options are :log
, :raise
, or :silence
Other options in the future, potentially. Maybe crib some ideas from https://api.rubyonrails.org/classes/ActiveSupport/Deprecation/Behavior.html#method-i-behavior-3D
Another thing to consider is expanding the scope of the error handling beyond connection errors. If that's desirable there might be a better way to design the configuration options.
from cable_ready.
@internets I like where you're going with this, Peter!
#168 has been merged (huzzah!) but I encourage you to open a draft PR for the API you'd like to see. 👍
from cable_ready.
Related Issues (20)
- Given multiple updates_for blocks with custom urls, only the first is re-fetched
- updates_for: add option to opt out of morphing if element is currently focused HOT 3
- updates_for: Support multiple enable_updates per model
- #165 reintroducing webpack issue HOT 4
- Helper generator Vite problems
- OperationBuilder#operations_payload messes with keys HOT 5
- Inlcude changed keys when broadcasting to model class? (updates_for :only) HOT 3
- Updatable's ActiveStorage implementation broadcasts to multiple/wrong keys HOT 7
- CR is overriding dom_id HOT 2
- ActiveRecord dependency breaks rspec on non AR Rails implementations HOT 6
- `updates_for` Makes Redundant Calls HOT 1
- Finalizer warning using Ruby 3.2.1 HOT 6
- Using an array with addCssClass does not update the classList correctly
- Improve updatable console logs/warnings
- Document updatable feature
- `inverse_of` returns `nil` when enriching `has_many` association with updates HOT 1
- Upgrading to v5.0.0.pre10 breaks Rails' named route helpers HOT 6
- Can't make `redirect_to` with `cablecar` functionnal with `rc2` HOT 4
- No such generator `cable_ready:stream_from` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cable_ready.