derbyjs / racer

Realtime model synchronization engine for Node.js
1.19k stars 118 forks source link

bugfix: don't resubscribe if isPathQuery #188

Closed minicuper closed 10 years ago

minicuper commented 10 years ago

The case:

Server rendering, unbundleing. Racer don't resubscribe to serialized docs for queries with ids-path (f.e. model.query('users', '_page.userIds')).

Racer subscribes only to new-docs (which will be added after reactive-function changes '_page.userIds'). But all serialized/deserialized '_page.userIds' docs stay without subscription.

You can try to recreate the bug using chat from derby-examples. After some chating (using two browsers or usual/incognito tabs) press f5, and then change user-name at the another tab. The name don't be changed in the first tab.

minicuper commented 10 years ago

Please, take a look, Nate. I think the bug is quite tricky.

nateps commented 10 years ago

This works pretty well, though it isn't 100% ideal. Put a comment in the code. Basically, you are making the assumption that the ids list is going to be the value at that path, which happens to generally work, but there are probably some edge cases here. I think this is the best change for now and it is certainly better, but i suspect there may be some crazy edge case that I didn't anticipate here.

minicuper commented 10 years ago

Of course is just a workaround but I haven't found the better solution yet.