voltrb / volt

A Ruby web framework where your Ruby runs on both server and client
MIT License
3.22k stars 196 forks source link

sync bug on master branch #277

Closed alexandred closed 9 years ago

alexandred commented 9 years ago

With a simple model structure, there is a bug related to syncing of model attributes across clients:

Relevant repository: https://github.com/alexandred/volt-sync-bug

Regression caused by commit: https://github.com/voltrb/volt/commit/97db9dddfc9e9c9043d0f75c48e4078fdc0e1f68

Setup:

Expected behaviour: Upon DOM unload or navigation by client A, client A's state should update on client B to "offline" (and vice versa). This works fine in 0.9.4 but not on the master branch of this git repo.

ryanstout commented 9 years ago

@alexandred this is a pretty complex example, can you narrow down the problem a bit? (Please make an example thats not using onbeforeunload, since that doesn't guarantee that the messages sent from it will get through)

ryanstout commented 9 years ago

@alexandred bundle update volt on master and see if it works now.

alexandred commented 9 years ago

@ryanstout it seems to be up to date, i can't see any new commits. Do you still need me to simplify the example?

ryanstout commented 9 years ago

Sorry, didn't push. Try again.

On Fri, Aug 21, 2015 at 11:44 AM, alexandred notifications@github.com wrote:

@ryanstout https://github.com/ryanstout it seems to be up to date, i can't see any new commits. Do you still need me to simplify the example?

— Reply to this email directly or view it on GitHub https://github.com/voltrb/volt/issues/277#issuecomment-133508280.

alexandred commented 9 years ago

@ryanstout With the latest commit I am now getting the following error on server start and on model attribute edits:

undefined method `singularize' for nil:NilClass
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/app/volt/tasks/store_tasks.rb:9:in `load_model'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/app/volt/tasks/store_tasks.rb:27:in `block (2 levels) in save'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/lib/volt/utils/modes.rb:24:in `run_in_mode'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/lib/volt/models/model.rb:349:in `block (2 levels) in <class:Model>'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/app/volt/tasks/store_tasks.rb:26:in `block in save'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/lib/volt/volt/users.rb:73:in `block in skip_permissions'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/lib/volt/utils/modes.rb:24:in `run_in_mode'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/lib/volt/volt/users.rb:72:in `skip_permissions'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/app/volt/tasks/store_tasks.rb:25:in `save'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/lib/volt/tasks/dispatcher.rb:119:in `block (2 levels) in dispatch_in_thread'
/Users/Alexandre/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/timeout.rb:91:in `block in timeout'
/Users/Alexandre/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/timeout.rb:35:in `block in catch'
/Users/Alexandre/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/timeout.rb:35:in `catch'
/Users/Alexandre/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/timeout.rb:35:in `catch'
/Users/Alexandre/.rvm/rubies/ruby-2.1.3/lib/ruby/2.1.0/timeout.rb:106:in `timeout'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/lib/volt/tasks/dispatcher.rb:116:in `block in dispatch_in_thread'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/gems/opal-0.8.0/stdlib/promise.rb:202:in `call'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/gems/opal-0.8.0/stdlib/promise.rb:202:in `resolve'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/gems/opal-0.8.0/stdlib/promise.rb:179:in `>>'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/gems/opal-0.8.0/stdlib/promise.rb:162:in `^'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/gems/opal-0.8.0/stdlib/promise.rb:272:in `then'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/lib/volt/tasks/dispatcher.rb:114:in `dispatch_in_thread'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/bundler/gems/volt-96a19dcbbaea/lib/volt/tasks/dispatcher.rb:57:in `block in dispatch'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/gems/concurrent-ruby-0.8.0/lib/concurrent/executor/ruby_thread_pool_worker.rb:62:in `call'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/gems/concurrent-ruby-0.8.0/lib/concurrent/executor/ruby_thread_pool_worker.rb:62:in `block in run'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/gems/concurrent-ruby-0.8.0/lib/concurrent/executor/ruby_thread_pool_worker.rb:53:in `loop'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/gems/concurrent-ruby-0.8.0/lib/concurrent/executor/ruby_thread_pool_worker.rb:53:in `run'
/Users/Alexandre/.rvm/gems/ruby-2.1.3@polymath/gems/concurrent-ruby-0.8.0/lib/concurrent/executor/ruby_thread_pool_executor.rb:255:in `block in create_worker_thread'
ryanstout commented 9 years ago

@alexandred ok, sorry, can you try updating master again one more time :-) Not sure why the last issue didn't get caught by the specs.

alexandred commented 9 years ago

@ryanstout This fixes the error introduced by the previous commit but unfortunately does not fix the original issue. Again, there are no errors in the volt log nor the browser log.

ryanstout commented 9 years ago

@alexandred ok, can you make me a simpler example project? (Maybe help me narrow it down a bit more) Thanks

dennym commented 9 years ago

This seems related to voltrb/volt#274 Its not a sync bug. Its just that the Storetask isn't doing what he is supposed to do. So thats why there is also no sync happening to the other client. I have the same issue but foudn out that the StoreTask isn't working the correct way.
Could it be this?

alexandred commented 9 years ago

Fixed by commit https://github.com/voltrb/volt/commit/37ec9ad5fb3de86e46b751816beda539e194deab