After further investigation today, the problem lies with the batch.map.batchId value which is set by taking the value of dwr.engine._nextBatchId within the _sendData method. The initial value of _nextBatchId = 0, so when we execute a call for the first time, the _batchesLength value is set to one. Once this call finishes and _clearUp is called the body of the if in the following code will not execute as the if statement will be false because batch.map.batchId==false;
// Will always be false for the first call as 0 == false
if(batch.map && batch.map.batchId)
{
delete dwr.engine._batches[batch.map.batchId];
dwr.engine._batchesLength--;
}
Which means that dwr.engine_batchesLength will never be zero. Subsequent calls where we have setOrdered to true will always add to the batchQueue and just sit there, because there is no longer a calll to return. I've modified engine.js to set the initial value of _nextBatchId = 1 as a quick fix as this was/is causing problems with our application. An alternative which might be nicer would be to change the if to;
if(batch.map && (batch.map.batchId || batch.map.batchId==0)) { .... }
I have noticed the same symptoms while using setOrdered. It appears once setOrdered is set to true, calls are added to the _batchQueue within the _endBatch method. It appears that these are not then popped from the queue and executed, unless the _clearUp method is called, which happens whenever the call has finished, either by throwing an exception/warning or by stateChange. I'm guessing that as the call is queued and doesn't appear to execute it will just sit there indefiniately ...