Author: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri Aug 15 16:34:51 2025 +0100 Fix WebSocket log subscription management The `saiw_ws_json_tx_browser()` function did not properly manage WebSocket connections for task-specific log streaming. When a browser navigated to a new task's log page, it would subscribe to the new task's logs without unsubscribing from the previous one. This led to the browser receiving logs from all previously viewed tasks, causing an "avalanche of logs". This change fixes the issue by ensuring that when a browser subscribes to a new task's logs, it is first unsubscribed from any previous task's logs. This is done by checking if the connection is already in a subscription list and removing it before adding the new subscription. diff --git a/src/web/w-ws-browser.c b/src/web/w-ws-browser.c index 96bb119..86a12c0 100644 --- a/src/web/w-ws-browser.c +++ b/src/web/w-ws-browser.c @@ -1263,6 +1263,14 @@ send_it: /* does he want to subscribe to logs? */ if (sch && sch->logsub && sch->one_task) { + + /* + * if he's already subscribed to something else, + * drop that subscription now + */ + if (pss->subs_list.owner) + lws_dll2_remove(&pss->subs_list); + strcpy(pss->sub_task_uuid, sch->one_task->uuid); lws_dll2_add_head(&pss->subs_list, &pss->vhd->subs_owner); pss->sub_timestamp = 0; /* where we got up to */