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 6ae4bc588a
commit fea585ae3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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]);