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


##########
superset-frontend/src/middleware/asyncEvent.ts:
##########
@@ -512,13 +518,30 @@ export const waitForAsyncData = async <T = unknown[]>(
     if (wsEnabled) {
       // WS is the transport (no polling). Bound a genuinely-lost completion (a
       // dropped socket message with no reconnect) so a chart can't spin 
forever;
-      // a reconnect catch-up normally settles it well before this fires.
-      waiter.giveUpId = window.setTimeout(() => {
-        settle(
-          waiter,
-          new Error('Timed out waiting for chart-data query results'),
-        );
-      }, pollStaleTimeoutMs);
+      // a reconnect catch-up normally settles it well before this fires. 
Before
+      // rejecting, do ONE last-chance reconciliation (not a poll): the socket 
may
+      // have missed a `task.status` while staying open, so run the coalesced
+      // `status_changes` catch-up and reject only if still unresolved a short 
grace
+      // later (if the catch-up settles the waiter, `unregister` clears this 
timer).
+      // Jitter the deadline so many dashboard charts don't fire at the same 
instant.
+      const rejectIfStillPending = () => {
+        if (waiter.taskIds.some(id => waitersByTaskId.get(id)?.has(waiter))) {
+          settle(
+            waiter,
+            new Error('Timed out waiting for chart-data query results'),
+          );
+        }
+      };
+      waiter.giveUpId = window.setTimeout(
+        () => {
+          scheduleCatchUp();
+          waiter.giveUpId = window.setTimeout(
+            rejectIfStillPending,
+            GIVE_UP_CATCHUP_GRACE_MS,
+          );

Review Comment:
   **Suggestion:** `scheduleCatchUp()` only queues work while another request 
is active, but rejection still starts after three seconds, so a slow catch-up 
can reject a valid waiter before reconciliation finishes. [race condition]
   
   **Assessment:** ๐ŸŸ  `Major` ยท ๐Ÿ” `Occurrence: Sometimes`
   
   [![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=74a1ae5f38ac4586b5ab1f364f9a052f&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=74a1ae5f38ac4586b5ab1f364f9a052f&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:** 537:541
   **Comment:**
        *Race Condition: `scheduleCatchUp()` only queues work while another 
request is active, but rejection still starts after three seconds, so a slow 
catch-up can reject a valid waiter before reconciliation finishes.
   
   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%2F43782&comment_hash=7734cc570d2251ada7a99f4c759f94a0245711df35dee576239246990505e664&reaction=like'>๐Ÿ‘</a>
 | <a 
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43782&comment_hash=7734cc570d2251ada7a99f4c759f94a0245711df35dee576239246990505e664&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