villebro commented on code in PR #43696:
URL: https://github.com/apache/superset/pull/43696#discussion_r3890555567
##########
superset-frontend/src/middleware/realtime.ts:
##########
@@ -131,6 +171,28 @@ const openSocket = (thisGeneration: number): void => {
return;
}
socket = ws;
+
+ // Proactively refresh the channel cookie and reconnect before this
+ // connection's token expires, so an idle realtime surface (one making no
other
+ // HTTP requests, e.g. a quiet list view) does not silently lose the socket
at
+ // JWT expiry. The GET re-mints the httponly cookie via the Flask
after_request
+ // hook (inside its sliding window); the reconnect then rides the fresh
token.
+ // Best-effort: reconnect regardless of the GET's outcome (a stale cookie
just
+ // fails the handshake, and onclose retries).
+ if (enabled && tokenLifetimeMs > 0) {
+ keepaliveTimeoutId = window.setTimeout(() => {
+ if (thisGeneration !== generation || !hasActiveSocket()) return;
+ SupersetClient.get({ endpoint: COOKIE_REFRESH_ENDPOINT })
+ .catch(() => {})
+ .finally(() => {
+ if (thisGeneration !== generation) return;
+ generation += 1;
+ teardownSocket();
+ openSocket(generation);
Review Comment:
Fixed in 0754fc0: the keepalive refresh now captures its socket instance and
bails in both the timer and the `.finally` if `socket !== ws` (a reconnect
already replaced it), so it can't tear down a newer healthy socket.
##########
superset-frontend/src/middleware/asyncEvent.ts:
##########
@@ -327,12 +323,18 @@ export const waitForAsyncData = async <T = unknown[]>(
): Promise<T> => {
const taskIds = asyncJob.task_ids ?? [];
+ // Capture the tab id once, in the same tick the 202 was received, and reuse
it
+ // for any later cancel/detach of these tasks. Reading it fresh at cancel
time
+ // could send a different id if the tab id was reassigned meanwhile (a
+ // duplicate-tab collision), orphaning the original per-tab subscription.
+ const submitTabId = getTabId();
Review Comment:
Fixed in 0754fc0: the server now echoes the recorded tab id in the 202 and
the client cancels with `asyncJob.tab_id`, so cancel uses exactly what the
backend stored as the consumer — closing the POST→202 reassignment window.
--
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]