@@ -17,7 +17,6 @@ import treeListCore from '../m_core';
1717const { queryByOptions } = storeHelper ;
1818
1919const DEFAULT_KEY_EXPRESSION = 'id' ;
20- const ERROR_MESSAGE = 'Operation cancelled due to operationId mismatch (possible race condition)' ;
2120
2221const isFullBranchFilterMode = ( that ) => that . option ( 'filterMode' ) === 'fullBranch' ;
2322
@@ -378,15 +377,19 @@ export class DataSourceAdapterTreeList extends DataSourceAdapter {
378377 } ;
379378 }
380379
381- private _loadParentsOrChildren ( data , options , needChildren ? ) {
382- if ( options . operationId !== undefined
380+ private _isOperationIdOutdated ( operationId ) {
381+ return operationId !== undefined
383382 && this . _lastOperationId !== undefined
384- && options . operationId !== this . _lastOperationId ) {
385- this . _dataSource . cancel ( options . operationId ) ; // Cancel the request
383+ && operationId !== this . _lastOperationId ;
384+ }
385+
386+ private _loadParentsOrChildren ( data , options , needChildren ?) {
387+ if ( this . _isOperationIdOutdated ( options . operationId ) ) {
388+ this . _dataSource . cancel ( options . operationId ) ;
386389 // @ts -expect-error
387390 const rejectedDeferred = new Deferred ( ) ;
388- rejectedDeferred . reject ( new Error ( ERROR_MESSAGE ) ) ;
389- return rejectedDeferred ; // Return rejected Deferred
391+ rejectedDeferred . reject ( ) ;
392+ return rejectedDeferred ;
390393 }
391394
392395 let filter ;
@@ -446,11 +449,9 @@ export class DataSourceAdapterTreeList extends DataSourceAdapter {
446449 const store = options . fullData ? new ArrayStore ( options . fullData ) : this . _dataSource . store ( ) ;
447450
448451 this . loadFromStore ( loadOptions , store ) . done ( ( loadedData ) => {
449- if ( options . operationId !== undefined
450- && this . _lastOperationId !== undefined
451- && options . operationId !== this . _lastOperationId ) {
452+ if ( this . _isOperationIdOutdated ( options . operationId ) ) {
452453 d . reject ( ) ;
453- return ; // Ignore outdated result
454+ return ;
454455 }
455456
456457 if ( loadedData . length ) {
0 commit comments