PDA

View Full Version : [FIXED] 4.2.1 reader.rawData retains data from last response on subsequent failed requests



welshcathy
25 Oct 2013, 12:01 AM
I've spotted a minor issue with rawData caching.

1st request is processed.
Response received ok.
proxy.processResponse() is called
Reader picks up say 999 records and stores in reader.rawData.

2nd request is processed.
404 or other failure so no response is received.
proxy.processResponse() is called
reader.rawData still holds 999 records from last call.
success = false forks the logic off away from the reader so the rawData is never reset.

This is typically not an issue with any standard ExtJs functions as on success = false the reader data is not inspected.
But we have additional custom function that inspects the request for any messages returned from the server.
I could add logic in our custom function to check the success state of the response before looking at the reader data - but I wanted to fix the root cause instead.

Patch
In proxy.processResponse() function add this patch - I'm overriding Ext.data.proxy.Server.



processResponse: function(success, operation, request, response, callback, scope) {
var me = this,
reader,
result;
// START PATCH ADDED TO CLEAR RAW DATA FROM PREVIOUS RESPONSE
reader = me.getReader();
reader.rawData = undefined;
// END PATCH ADDED TO CLEAR RAW DATA FROM PREVIOUS RESPONSE
if (success === true) {
reader = me.getReader();


Cheers,

Cathy

Gary Schlosberg
26 Oct 2013, 3:07 PM
Thanks for the report! I checked with a developer who thought it would break things for people if the behavior changed. I have opened a documentation bug in our bug tracker so we can clarify the behavior in the API docs.