From fd036b2952e127cf086f58ea68e33138ad2e166f Mon Sep 17 00:00:00 2001 From: Akanksha Trehun Date: Wed, 19 Aug 2026 20:28:20 +0530 Subject: [PATCH] fix(knative): clean up blob URL and DOM node after log download downloadPlainLogs creates an anchor element and an object URL for every download but never removes either. kompose's download button and ai-assistant's LogsDialog both already revoke the URL and remove the element right after triggering the click (LogsDialog does it in a finally so it still happens if click() throws) - this one didn't, so each download left a detached anchor in the DOM and pinned the blob in memory for the rest of the session. Same pattern as those two now. Signed-off-by: Akanksha Trehun --- .../detail/header/KServiceLogsHeaderButton.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/knative/src/components/kservices/detail/header/KServiceLogsHeaderButton.tsx b/knative/src/components/kservices/detail/header/KServiceLogsHeaderButton.tsx index eec77c43bc..ae38c9594c 100644 --- a/knative/src/components/kservices/detail/header/KServiceLogsHeaderButton.tsx +++ b/knative/src/components/kservices/detail/header/KServiceLogsHeaderButton.tsx @@ -396,11 +396,17 @@ function KServiceLogsActivityContent({ kservice }: { kservice: KService }) { const element = document.createElement('a'); const file = new Blob([downloadLogs.join('')], { type: 'text/plain' }); - element.href = URL.createObjectURL(file); + const url = URL.createObjectURL(file); + element.href = url; element.download = `${downloadName}_${time}.txt`; - // Required for FireFox - document.body.appendChild(element); - element.click(); + try { + // Required for FireFox + document.body.appendChild(element); + element.click(); + } finally { + element.remove(); + URL.revokeObjectURL(url); + } } React.useEffect(() => {