GridCore dataController: reset guard flags when the guarded action throws - #34705
GridCore dataController: reset guard flags when the guarded action throws#34705bit-byte0 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens the Grid data controller’s internal guard flags so they always reset even when guarded operations throw, preventing the controller from getting “wedged” and suppressing later sorting/grouping or paging processing.
Changes:
- Introduces a small guard utility (
runGuarded) with a mutableFlagobject to ensure flags are lowered viatry/finally. - Adds Jest tests validating
createFlagandrunGuardedbehavior (including the throwing path). - Updates
DataControllerto userunGuardedfor sorting/grouping and paging guard sections, and switches boolean checks to.value.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/devextreme/js/__internal/grids/grid_core/data_controller/utils/guards.ts | Adds a helper to raise/lower guard flags around a critical section using try/finally. |
| packages/devextreme/js/__internal/grids/grid_core/data_controller/utils/tests/guards.test.ts | Adds Jest coverage for the new guard helper (flag raising/lowering + throwing path). |
| packages/devextreme/js/__internal/grids/grid_core/data_controller/data_controller.ts | Replaces manual flag toggling with runGuarded and updates guard checks to use Flag.value. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.
Suppressed comments (1)
packages/devextreme/js/__internal/grids/grid_core/data_controller/utils/guards.ts:5
- For consistency with other utils in this folder, exported helpers are declared as functions (e.g. utils/paging.ts:3
export function resolvePaginate, utils/row_values.ts:6export function generateRowValues). Consider switchingcreateFlagfrom an exported const to anexport functionas well.
export const createFlag = (): Flag => ({ value: false });
…action throws (T7)
dfe672b to
35fcc49
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (2)
packages/devextreme/js/__internal/grids/grid_core/data_controller/data_controller.ts:1595
- Consider adding a Jest regression test for the paging guard that forces an exception during paging option application (e.g., make
dataSource.pageIndex/dataSource[optionName]throw) and asserts_skipProcessingPagingChangeis cleared in all cases. Without a test, it’s easy for future edits to reintroduce the stuck-flag issue.
this._skipProcessingPagingChange = true;
try {
if (optionName === 'pageSize' && value === 0) {
dataSource.pageIndex(0);
this.option('paging.pageIndex', 0);
packages/devextreme/js/__internal/grids/grid_core/data_controller/data_controller.ts:443
- Consider adding a Jest regression test that simulates
columnsController.updateSortingGrouping(...)throwing and verifies the controller doesn’t stay wedged (i.e.,_columnsUpdatingis reset tofalse, so subsequent sorting/groupingcolumnsChangedcan proceed). This change is specifically about exception safety and is hard to validate without a test.
This issue also appears on line 1591 of the same file.
this._columnsUpdating = true;
try {
columnsController.updateSortingGrouping(dataSource, !this._useSortingGroupingFromColumns);
} finally {
this._columnsUpdating = false;
What
The data controller's guard flags (
_columnsUpdating,_skipProcessingPagingChange) now reset even when the guarded operation throws. Previously a throw inupdateSortingGroupingskipped_columnsUpdating = falseand wedged the controller, permanently suppressing later sorting/groupingcolumnsChangedevents.How
Both guarded blocks are wrapped in
try/finallyso the flags reset even if the operation throws.