Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
    npro  
 Modern all-safe Rust Network Protocol library supporting h1, h2, h3, ws, wt sans-IO and with socket IO + tls
git clone https://npro.rs/repo/npro
Author[]google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.c...> 2025-08-15 15:34 UTC
Committer[]Andy Green <andy@warmcat.com> 2025-08-15 15:36 UTC
Tree0d48094b7e1a32e28f39db7ae1a2c018476796d6   Raw Patch
 
Fix WebSocket log subscription management
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 */
Page fetched 0s ago, creation time: 2ms (vhost etag hits: 0%, cache hits: 0%)