简体   繁体   中英

ODATA request aborted

Sometimes, the odata request crashed in my specific app in SAPUI5 (no error on the GW side in iwfnd/error_log). If I replay the call in chrome network tab it always works.

I get this error :The following problem occurred: Request aborted -

The SAPUI5 version used is : "1.38.9". Here is the stack :

O   @   sap-ui-core.js:formatted:9550
Q.fatal @   sap-ui-core.js:formatted:9571
h._handleError  @   ODataModel.js:6
k   @   ODataModel.js:6
(anonymous) @   ODataModel.js:6
i.abort @   datajs.js:17
abort   @   ODataModel.js:6
c.abortPendingRequest   @   ODataListBinding.js:6
c.filter    @   ODataListBinding.js:6

It is in the case of a "master detail" scenario when I click on an item in the "master" list I filter some data in the detail. The problem is that the data is actually not updated as the Odata request abort. Here is the short version of the code :

    _onRouteMatched: function(oEvent) {
filterCharac.push(new sap.ui.model.Filter("Zrwk", sap.ui.model.FilterOperator.EQ, oArgs.idRework));
      filterCharac.push(new sap.ui.model.Filter("Ztasknb", sap.ui.model.FilterOperator.EQ, oArgs.taskId));
      this.getView().byId("TableCharac").getBinding("items").filter(filterCharac);
      this.getView().byId("StatusLog").getBinding("items").filter(new sap.ui.model.Filter("Zrwk", sap.ui.model.FilterOperator.EQ, oArgs.idRework));
      this.getView().byId("lowestItems").getBinding("items").filter(filterCharac);
      var commentsFeed = this.getView().byId("Comments");
      var oFilter = new sap.ui.model.Filter("Zrwk", sap.ui.model.FilterOperator.EQ, oArgs.idRework); // name between A and G
      commentsFeed.getBinding("items").filter(oFilter);

}

This mostly happens when a request for obtaining some data (eg the complete list contents) is aborted because a filtering (or sorting) is applied to the list before the request has completed. Because UI5 detects that the data initially requested will no longer be "useful", it aborts the request.

The following comment from the UI5 code explains this ( code is on github ):

/*    
 * Aborts the current pending request (if any).
 *
 * This can be called if we are sure that the data from the 
 * current request is no longer relevant, e.g. when filtering / 
 * sorting is triggered or the context is changed.
 */

Theoretically, this should not affect the behavior of your application (but I guess it is ugly to see the errors in the console). You can avoid this by applying the filtering earlier on the aggregation (eg directly in the view instead of inside the controller).

If you can show us what aggregation you are filtering (probably from JS) and how you define it in the view, maybe we can come up with a more specific solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM