bito-code-review[bot] commented on PR #43436:
URL: https://github.com/apache/superset/pull/43436#issuecomment-5387740855

   <!-- Bito Reply -->
   The flagged issue is correct. When `GlobalAsyncQueries` is disabled, 
`waitersByTaskId` is not initialized, but `handleRealtimeMessage` is still 
subscribed to the shared realtime client and will attempt to access 
`waitersByTaskId` when a message arrives, causing a `TypeError`.
   
   To resolve this, you should initialize `waitersByTaskId` regardless of the 
feature flag, or guard the `applyStatus` call within `handleRealtimeMessage` to 
ensure it only proceeds if the map is initialized.
   
   Here is a concise fix for `superset-frontend/src/middleware/asyncEvent.ts`:
   
   ```typescript
   export const handleRealtimeMessage = (message: RealtimeMessage) => {
     if (!waitersByTaskId) return;
     const { channel, payload } = message;
     if (!channel.startsWith(REALTIME_CHANNEL_PREFIX)) return;
     const taskId = payload?.task_id;
     const status = payload?.status;
     if (typeof taskId === 'string' && typeof status === 'string') {
       applyStatus(taskId, status);
     }
   };
   ```
   
   Would you like me to fetch and validate the rest of the comments on this PR 
to see if there are other issues to address?
   
   **superset-frontend/src/middleware/asyncEvent.ts**
   ```
   export const handleRealtimeMessage = (message: RealtimeMessage) => {
     if (!waitersByTaskId) return;
     const { channel, payload } = message;
     if (!channel.startsWith(REALTIME_CHANNEL_PREFIX)) return;
     const taskId = payload?.task_id;
     const status = payload?.status;
     if (typeof taskId === 'string' && typeof status === 'string') {
       applyStatus(taskId, status);
     }
   };
   ```


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