bito-code-review[bot] commented on code in PR #43805:
URL: https://github.com/apache/superset/pull/43805#discussion_r4064485466
##########
superset-frontend/src/dashboard/components/menu/DownloadMenuItems/index.tsx:
##########
@@ -167,6 +213,98 @@ export const useDownloadMenuItems = (
}
};
+ const triggerExportDownload = (downloadUrl: string) => {
+ // Stream the file straight to disk via a hidden iframe. The endpoint sends
+ // Content-Disposition: attachment, so the browser saves it without
+ // navigating the dashboard away (fatal inside an embedded iframe) and
+ // without buffering the whole workbook in tab memory the way
fetch().blob()
+ // would. The status endpoint already confirmed the link is ready and
+ // backend-matched, so the only failure left is the narrow race where the
+ // object is removed between that check and this click; such an error
+ // response loads invisibly in the iframe and leaves the page untouched.
+ const iframe = document.createElement('iframe');
+ iframe.style.display = 'none';
+ iframe.src = downloadUrl;
+ document.body.appendChild(iframe);
+ // Removing the iframe before the response commits cancels the request, and
+ // time to first byte is unbounded (slow storage, busy web server), so hold
+ // it until unmount rather than racing a timer against the download.
+ downloadFramesRef.current.push(iframe);
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>iframe accumulation on repeat exports</b></div>
<div id="fix">
Every export now pushes a hidden iframe into `downloadFramesRef` and only
removes it on unmount (lines 101-102). On a long-lived dashboard, repeated
exports (data, images, re-exports) accumulate unbounded hidden frames in
`document.body`; the old code cleaned each up after
`EXPORT_STATUS_POLL_INTERVAL_MS`. Consider removing on the iframe's `load`
event (fires once the response is received) so completed downloads don't linger.
</div>
</div>
<small><i>Code Review Run #0a74c9</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]