bito-code-review[bot] commented on PR #43252:
URL: https://github.com/apache/superset/pull/43252#issuecomment-5314706256

   <!-- Bito Reply -->
   The flagged race condition is correct. To resolve this, you should track the 
request generation (e.g., using a counter or timestamp) and ignore any 
responses that arrive out of order. 
   
   Here is a concise implementation to track request generations in 
`superset-frontend/src/dashboard/actions/nativeFilters.ts`:
   
   ```typescript
   // Add a module-level variable to track the latest request generation
   let latestRequestGeneration = 0;
   
   export const setFilterConfiguration = (filterChanges: any) => async 
(dispatch: Dispatch, getState: () => RootState) => {
     const currentGeneration = ++latestRequestGeneration;
     try {
       const response = await updateFilters(filterChanges);
       // Ignore stale responses
       if (currentGeneration !== latestRequestGeneration) return;
       
       const savedFilters = response.result.map(
         filter => omit(filter, ['chartsInScope', 'tabsInScope']) as Filter,
       );
       // ... dispatch actions
     } catch (err) {
       if (currentGeneration !== latestRequestGeneration) return;
       // ... handle error
     }
   };
   ```
   
   I have checked the PR comments, and there are no other comments to address. 
Would you like me to fetch all comments to be sure?
   
   **superset-frontend/src/dashboard/actions/nativeFilters.ts**
   ```
   let latestRequestGeneration = 0;
   
   export const setFilterConfiguration = (filterChanges: any) => async 
(dispatch: Dispatch, getState: () => RootState) => {
     const currentGeneration = ++latestRequestGeneration;
     try {
       const response = await updateFilters(filterChanges);
       if (currentGeneration !== latestRequestGeneration) return;
       
       const savedFilters = response.result.map(
         filter => omit(filter, ['chartsInScope', 'tabsInScope']) as Filter,
       );
       // ... dispatch actions
     } catch (err) {
       if (currentGeneration !== latestRequestGeneration) return;
       // ... handle error
     }
   };
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to