From 700073df8a9964654afc5ba45136401a61545d93 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 19 Aug 2020 19:11:49 -0700 Subject: [PATCH] fix bug where image load errors would keep loading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dice reported this, thank you! My mistake here was that `loadImage` _does_ reject when the image fails to load… but it ends up throwing `undefined`, since I forgot to pass the error along from `onerror` to `reject`! So we would cancel stuff, but then store `undefined` as our error in state, which our component interprets as no-error. I tested this by using Firefox DevTools request blocking! --- src/app/components/OutfitPreview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/components/OutfitPreview.js b/src/app/components/OutfitPreview.js index 53e45df..6a1bbd3 100644 --- a/src/app/components/OutfitPreview.js +++ b/src/app/components/OutfitPreview.js @@ -212,7 +212,7 @@ function loadImage(url) { const image = new Image(); const promise = new Promise((resolve, reject) => { image.onload = () => resolve(); - image.onerror = () => reject(); + image.onerror = (e) => reject(e); image.src = url; }); promise.cancel = () => {