fix: Reject image/video dimension promises with real Error (#12498)

The onerror handlers in FileHelper passed the raw DOM Event to reject,
which Sentry surfaced as "Event captured as promise rejection" with no
stack. Reject with an Error and revoke the blob URL on failure.
This commit is contained in:
Tom Moor
2026-05-27 22:34:55 -04:00
committed by GitHub
parent 7473d5b437
commit c158697c91
+8 -2
View File
@@ -80,7 +80,10 @@ export default class FileHelper {
window.URL.revokeObjectURL(video.src);
resolve({ width: video.videoWidth, height: video.videoHeight });
};
video.onerror = reject;
video.onerror = () => {
window.URL.revokeObjectURL(video.src);
reject(new Error("Failed to load video for dimensions"));
};
video.src = URL.createObjectURL(file);
});
}
@@ -154,7 +157,10 @@ export default class FileHelper {
resolve({ width: img.width, height: img.height });
};
img.onerror = reject;
img.onerror = () => {
window.URL.revokeObjectURL(img.src);
reject(new Error("Failed to load image for dimensions"));
};
img.src = URL.createObjectURL(file);
});
}