codeant-ai-for-open-source[bot] commented on code in PR #43461:
URL: https://github.com/apache/superset/pull/43461#discussion_r3844429140
##########
superset-frontend/src/middleware/asyncEvent.ts:
##########
@@ -217,8 +216,15 @@ export const waitForAsyncData = async <T = unknown[]>(
signal?: AbortSignal,
): Promise<T> => {
const taskIds = asyncJob.task_ids ?? [];
- if (baselineReady) await baselineReady;
+ // Register the waiter synchronously, in the same tick the 202 was received —
+ // NOT after an await. The 202 is returned when the tasks are *scheduled*,
not
+ // finished, so at this point the shared poll cursor is <= now < any task's
+ // future terminal transition; the poll is therefore guaranteed to observe
the
+ // completion. Awaiting anything here (e.g. the init baseline) would open a
gap
+ // in which a fast task could finish and a concurrent chart's poll advance
the
+ // cursor past its terminal update, and the socket event (no waiter yet)
would
+ // be dropped — hanging the request.
await new Promise<void>((resolve, reject) => {
Review Comment:
**Suggestion:** Registering the waiter synchronously does not eliminate the
baseline race because `init()` performs the baseline request asynchronously. A
chart can receive its 202 and register here before that baseline resolves; if
the task reaches a terminal state before the baseline response, the baseline
cursor can be newer than the task transition and the first poll will
permanently skip it when the websocket event is unavailable. Preserve a
readiness mechanism that prevents cursor advancement past tasks registered
before the baseline, while keeping waiter registration synchronous. [race
condition]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Chart data requests can remain pending indefinitely.
- ❌ Native-filter async requests can hang without websocket delivery.
- ⚠️ The shared status poll permanently skips affected task transitions.
```
</details>
[](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/middleware/asyncEvent.ts
**Line:** 228:228
**Comment:**
*Race Condition: Registering the waiter synchronously does not
eliminate the baseline race because `init()` performs the baseline request
asynchronously. A chart can receive its 202 and register here before that
baseline resolves; if the task reaches a terminal state before the baseline
response, the baseline cursor can be newer than the task transition and the
first poll will permanently skip it when the websocket event is unavailable.
Preserve a readiness mechanism that prevents cursor advancement past tasks
registered before the baseline, while keeping waiter registration synchronous.
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%2F43461&comment_hash=8a68388e7a9d9ab530871b732271b70123fb6c69a532767828e52ea193d2a6d7&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F43461&comment_hash=8a68388e7a9d9ab530871b732271b70123fb6c69a532767828e52ea193d2a6d7&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]