Skip to content

Commit 86e193c

Browse files
committed
fix by Copilot review
1 parent f91f269 commit 86e193c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

packages/devextreme/js/__internal/grids/tree_list/data_source_adapter/m_data_source_adapter.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ describe('TreeList DataSourceAdapter - T1311885 Race Condition', () => {
108108
(dataSourceAdapter as any)._cachedStoreData = parentData;
109109
(dataSourceAdapter as any)._dataSource = {
110110
store: jest.fn(() => mockStore),
111+
cancel: jest.fn(),
111112
};
112113
(dataSourceAdapter as any)._lastOperationId = OPERATION_ID.FIRST;
113114

packages/devextreme/js/__internal/grids/tree_list/data_source_adapter/m_data_source_adapter.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import treeListCore from '../m_core';
1717
const { queryByOptions } = storeHelper;
1818

1919
const DEFAULT_KEY_EXPRESSION = 'id';
20+
const ERROR_MESSAGE = 'Operation cancelled due to operationId mismatch (possible race condition)';
2021

2122
const isFullBranchFilterMode = (that) => that.option('filterMode') === 'fullBranch';
2223

@@ -381,10 +382,10 @@ export class DataSourceAdapterTreeList extends DataSourceAdapter {
381382
if (options.operationId !== undefined
382383
&& this._lastOperationId !== undefined
383384
&& options.operationId !== this._lastOperationId) {
384-
this._dataSource.close(options.operationId); // Cancel the request
385+
this._dataSource.cancel(options.operationId); // Cancel the request
385386
// @ts-expect-error
386387
const rejectedDeferred = new Deferred();
387-
rejectedDeferred.reject();
388+
rejectedDeferred.reject(new Error(ERROR_MESSAGE));
388389
return rejectedDeferred; // Return rejected Deferred
389390
}
390391

@@ -448,6 +449,7 @@ export class DataSourceAdapterTreeList extends DataSourceAdapter {
448449
if (options.operationId !== undefined
449450
&& this._lastOperationId !== undefined
450451
&& options.operationId !== this._lastOperationId) {
452+
d.reject();
451453
return; // Ignore outdated result
452454
}
453455

0 commit comments

Comments
 (0)