creately / rxdata

A reactive document database for web browsers
MIT License
11 stars 1 forks source link

Fix collection inserted data not available bug #62

Closed thani-sh closed 5 years ago

thani-sh commented 5 years ago

Bug

Changes made on step 2 will not be there on results. This only happens when the first operation made on the collection is an insert or an update and a read is performed immediately after that. There's a race condition so it may not happen all the time (can be recreated by adding a wait time inside apple method).

This happens because the insert operation attempts to read already available data from the indexed db and starts the load operation. This operation will return an empty array (before the read). If a find operation is started before load completes, it will also wait on the same promise created by the insert operation which emits an empty array.

Fix