mirror of
https://github.com/outline/outline.git
synced 2026-06-13 03:14:59 +03:00
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:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user