codeant-ai-for-open-source[bot] commented on code in PR #43424:
URL: https://github.com/apache/superset/pull/43424#discussion_r3836574553


##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx:
##########
@@ -292,7 +294,14 @@ const FilterValue: FC<FilterValueProps> = ({
               setError(undefined);
               handleFilterLoadFinish();
             } else if (response.status === 202) {
-              waitForAsyncData(result as Parameters<typeof 
waitForAsyncData>[0])
+              // Await the query tasks, then re-issue the request to read the
+              // now-cached results.
+              waitForAsyncData(json as unknown as AsyncJob, () =>
+                requestFilterData(true).then(
+                  ({ json: cachedJson }) =>
+                    cachedJson.result as ChartDataResponseResult[],
+                ),
+              )

Review Comment:
   **Suggestion:** The asynchronous filter request has no abort or 
stale-request guard. If filter state changes while `waitForAsyncData` is 
polling, the captured `newFormData` request can eventually refetch and call 
`setState` and `handleFilterLoadFinish` after a newer filter request has 
started, allowing old options to overwrite current values and clearing the 
newer request's loading state. Create an effect-scoped `AbortController` and 
ignore or cancel completion from superseded requests. [stale reference]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Native filter options can briefly reflect obsolete selections.
   - ⚠️ Old completion can clear the current filter's loading state.
   - ⚠️ Async default-value loading has the same pattern.
   ```
   </details>
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterControls/FilterValue.tsx
   **Line:** 299:304
   **Comment:**
        *Stale Reference: The asynchronous filter request has no abort or 
stale-request guard. If filter state changes while `waitForAsyncData` is 
polling, the captured `newFormData` request can eventually refetch and call 
`setState` and `handleFilterLoadFinish` after a newer filter request has 
started, allowing old options to overwrite current values and clearing the 
newer request's loading state. Create an effect-scoped `AbortController` and 
ignore or cancel completion from superseded requests.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43424&comment_hash=1be9e3f40c9a3276bf191b9858beaeb7c2c9828a877212205caaf77d79f6fd98&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43424&comment_hash=1be9e3f40c9a3276bf191b9858beaeb7c2c9828a877212205caaf77d79f6fd98&reaction=dislike'>👎</a>



##########
superset-frontend/src/features/versionHistory/ChartVersionPreview.tsx:
##########
@@ -175,10 +175,16 @@ export default function ChartVersionPreview() {
         datasourceId,
         datasourceType,
       );
-      const { response, json } = await getChartDataRequest({
-        formData: previewFormData,
-      });
-      const result = await handleChartDataResponse(response, json);
+      const requestPreviewData = () =>
+        getChartDataRequest({
+          formData: previewFormData,
+        });
+      const { response, json } = await requestPreviewData();
+      const result = await handleChartDataResponse(response, json, () =>
+        requestPreviewData().then(({ response: r, json: j }) =>
+          handleChartDataResponse(r, j),
+        ),

Review Comment:
   **Suggestion:** The preview's async wait is started without an 
`AbortSignal`, so changing versions or unmounting the preview only prevents the 
final state update via `fetchId`; it does not stop polling or cancel the 
outstanding GTF tasks. Repeated preview changes can therefore retain waiters 
and continue warehouse work until each task finishes. Pass a lifecycle-scoped 
signal through the response handler and abort it when the preview request is 
superseded or unmounted. [resource leak]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ⚠️ Abandoned version previews retain polling waiters.
   - ⚠️ Outstanding GTF chart tasks continue after preview changes.
   - ⚠️ Repeated preview changes increase unnecessary warehouse work.
   ```
   </details>
   
   [![Use CodeAnt 
Skill](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/use-codeant-skill-flat-v2.svg)](https://docs.codeant.ai/cli/resolve-pr-comments-skill)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** 
superset-frontend/src/features/versionHistory/ChartVersionPreview.tsx
   **Line:** 182:186
   **Comment:**
        *Resource Leak: The preview's async wait is started without an 
`AbortSignal`, so changing versions or unmounting the preview only prevents the 
final state update via `fetchId`; it does not stop polling or cancel the 
outstanding GTF tasks. Repeated preview changes can therefore retain waiters 
and continue warehouse work until each task finishes. Pass a lifecycle-scoped 
signal through the response handler and abort it when the preview request is 
superseded or unmounted.
   
   Validate the correctness of the flagged issue. If correct, How can I resolve 
this? If you propose a fix, implement it and please make it concise.
   Once fix is implemented, also check other comments on the same PR, and ask 
user if the user wants to fix the rest of the comments as well. if said yes, 
then fetch all the comments validate the correctness and implement a minimal fix
   ```
   </details>
   <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43424&comment_hash=24762bea5e034b4e47f7fa3ccfe28390ddd37a22a360b206d3a629c8f4818d71&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43424&comment_hash=24762bea5e034b4e47f7fa3ccfe28390ddd37a22a360b206d3a629c8f4818d71&reaction=dislike'>👎</a>



-- 
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