fix: prevent DOM error when removing temporary download link (#675) (#676)

Add defensive checks before removeChild to prevent 'Failed to execute removeChild' error when the element has already been removed from DOM. Wrap URL.revokeObjectURL in finally block to ensure proper resource cleanup.
This commit is contained in:
Willem Jiang 2025-10-31 22:30:34 +08:00 committed by GitHub
parent 4395392558
commit 452ecd77b9
1 changed files with 7 additions and 2 deletions

View File

@ -87,8 +87,13 @@ export function ResearchBlock({
document.body.appendChild(a);
a.click();
setTimeout(() => {
document.body.removeChild(a);
URL.revokeObjectURL(url);
try {
if (a.parentNode) {
a.parentNode.removeChild(a);
}
} finally {
URL.revokeObjectURL(url);
}
}, 0);
}, [reportId]);