villebro commented on code in PR #43461:
URL: https://github.com/apache/superset/pull/43461#discussion_r3844631669


##########
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:
   Good catch — you're right that synchronous registration alone did not close 
the polling-only path, because the init baseline cursor is fetched 
asynchronously and stamped with the server's now() at resolve time, which can 
post-date an early task. Fixed in 31a22c9f47 with a cleaner approach than a 
per-task lookup: `submit_chart_data_query_tasks` now captures a status-poll 
cursor **before any task is created** and returns it in the 202 alongside 
`task_ids`. Since it predates every task's creation, the client polls its 
waiter from that cursor and can never skip a terminal — no dependence on the 
baseline timestamp. It's one small value per response (echoing every task id 
back would bloat requests for large dashboards). The client rewinds its shared 
poll cursor to it on registration, and the init baseline now only *seeds* the 
cursor when unset so it can't clobber that rewind. Regression tests: the 202 
carries the cursor (unit + integration) and the poll issues a request using it.



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