Opened 2 years ago

Last modified 20 months ago

#18956 assigned defect

invalid out-of-date-check in dojo/store/Observable

Reported by: gerhard presser Owned by: dylan
Priority: high Milestone: 1.14
Component: Data Version: 1.10.2
Keywords: Cc:
Blocked By: Blocking:

Description

following scenario:

observable-json-rest store with one active, observed query.

a array of updates flys in by e.g. cometd.

var store = Observable(new JsonRest({..}));

on("message",function(data) {
  array.forEach(data,function(item) {
     store.notify(item,item.id);
  });
);

while processing the messages, on certain updates, the application logic triggers a new query on the store...(in my case, a dgrid starts to preload new pages of items)

var result = store.query(....);
result.observe(function() {
  //do something...
});

the store then triggers an async server request. the store.notify() loop still continues to update the store.

when the query-result is available, I get following error in the console.

Query is out of date, you must observe() the query prior to any data modifications

If you take a look at the dojo/store/Observable implementation:

-) store.revision is updated on every store.notify() call

-) the query-updaters are called on every store.notify() call, but use

when(results, function(resultsArray){
...process updates...
});

therefore, the actual processing of the notification may also be async. in the meantime, N more notifies may cause the store.revision to be bumped up.

when the result is finally ready, the query-revision may never be up-to-date, even though the result.observe() setup is always correct.

IMO the check for the revision should be performed immediately when the updater is invoked.

queryUpdaters.push(queryUpdater = function(changed, existingId){

	if(++queryRevision != revision){
		throw new Error("Query is out of date, you must observe() the query prior to any data modifications");
	}
						
	when(results, function(resultsArray){
		var atEnd = resultsArray.length != options.count;
		...

Change History (3)

comment:1 Changed 2 years ago by dylan

Component: GeneralData
Milestone: tbd1.12.2
Owner: set to dylan
Priority: undecidedhigh
Status: newassigned

comment:2 Changed 2 years ago by dylan

Milestone: 1.12.21.12.3

comment:3 Changed 20 months ago by dylan

Milestone: 1.12.31.14
Note: See TracTickets for help on using tickets.