mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
Correctly apply image timeout for loading images
This commit is contained in:
parent
c093c95881
commit
bd463d9343
@ -78,10 +78,12 @@ export default class ImageLoader<T> {
|
||||
}
|
||||
}
|
||||
};
|
||||
xhr.ontimeout = () => reject(`Timed out fetching ${src}`);
|
||||
xhr.responseType = 'blob';
|
||||
if (this.options.imageTimeout) {
|
||||
xhr.timeout = this.options.imageTimeout;
|
||||
const timeout = this.options.imageTimeout;
|
||||
xhr.timeout = timeout;
|
||||
xhr.ontimeout = () =>
|
||||
reject(__DEV__ ? `Timed out (${timeout}ms) fetching ${src}` : '');
|
||||
}
|
||||
xhr.open('GET', src, true);
|
||||
xhr.send();
|
||||
@ -122,6 +124,13 @@ export default class ImageLoader<T> {
|
||||
resolve(img);
|
||||
}, 500);
|
||||
}
|
||||
if (this.options.imageTimeout) {
|
||||
const timeout = this.options.imageTimeout;
|
||||
setTimeout(
|
||||
() => reject(__DEV__ ? `Timed out (${timeout}ms) fetching ${src}` : ''),
|
||||
timeout
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
this.cache[key] =
|
||||
|
@ -19,7 +19,7 @@ export type Options = {
|
||||
async: ?boolean,
|
||||
allowTaint: ?boolean,
|
||||
canvas: ?HTMLCanvasElement,
|
||||
imageTimeout: ?number,
|
||||
imageTimeout: number,
|
||||
proxy: ?string,
|
||||
removeContainer: ?boolean,
|
||||
scale: number,
|
||||
|
Loading…
Reference in New Issue
Block a user