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


##########
superset-frontend/src/middleware/asyncEvent.ts:
##########
@@ -152,6 +152,18 @@ const cancelTask = (taskId: string) => {
   });
 };
 
+// Cancel only tasks no local waiter still needs. A SHARED task can back 
several
+// charts for the same principal through a single backend subscriber, so
+// cancelling one chart while another local waiter still awaits the same task 
id
+// would tell the server the last subscriber left and abort work the other 
chart
+// needs. Call *after* removing the aborting waiter (or before registering it),
+// so a task id still present in the registry means another waiter depends on 
it.
+const cancelUnwaitedTasks = (taskIds: string[]) => {
+  taskIds.forEach(taskId => {
+    if (!waitersByTaskId.has(taskId)) cancelTask(taskId);

Review Comment:
   **Suggestion:** The waiter registry is scoped to this JavaScript module 
instance, so it cannot observe charts waiting in another browser tab or window. 
When the last local waiter aborts, this condition sends `/cancel` even if 
another tab for the same principal still depends on the shared task; the 
backend can then unsubscribe the principal and abort work needed by that other 
chart. Coordinate cancellation across browser contexts or make cancellation 
depend on the backend's principal-level subscriber state rather than only this 
local map. [race condition]
   
   <details>
   <summary><b>Severity Level:</b> Major ⚠️</summary>
   
   ```mdx
   - ❌ One tab can abort work required by another tab.
   - ❌ The surviving chart receives a failed async result.
   - ⚠️ Trigger requires identical shared requests across browser contexts.
   ```
   </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)
 [![Fix in 
Cursor](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-cursor-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=d6d7f0d7d61241f68fcd8a46b58463e6&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
 [![Fix in VSCode 
Claude](https://new-codeant-butcket.s3.us-west-1.amazonaws.com/badges/fix-in-vscode-claude-flat.svg)](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=d6d7f0d7d61241f68fcd8a46b58463e6&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
   <details>
   <summary><b>Prompt for AI Agent 🤖 </b></summary>
   
   ```mdx
   This is a comment left during a code review.
   
   **Path:** superset-frontend/src/middleware/asyncEvent.ts
   **Line:** 163:163
   **Comment:**
        *Race Condition: The waiter registry is scoped to this JavaScript 
module instance, so it cannot observe charts waiting in another browser tab or 
window. When the last local waiter aborts, this condition sends `/cancel` even 
if another tab for the same principal still depends on the shared task; the 
backend can then unsubscribe the principal and abort work needed by that other 
chart. Coordinate cancellation across browser contexts or make cancellation 
depend on the backend's principal-level subscriber state rather than only this 
local map.
   
   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%2F43685&comment_hash=ba769bafb08ce9a4bfac062e0afa44b58c546b387211523493e5a563428f510b&reaction=like'>👍</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43685&comment_hash=ba769bafb08ce9a4bfac062e0afa44b58c546b387211523493e5a563428f510b&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