Skip to content

Commit 1702caf

Browse files
committed
Cache fetch promise and clear on error
1 parent 475d91e commit 1702caf

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/geotiffimage.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -382,12 +382,12 @@ class GeoTIFFImage {
382382
offset = this.fileDirectory.StripOffsets[index];
383383
byteCount = this.fileDirectory.StripByteCounts[index];
384384
}
385-
const slice = (await this.source.fetch([{ offset, length: byteCount }], signal))[0];
386385

387386
let request;
388387
if (tiles === null || !tiles[index]) {
389388
// resolve each request by potentially applying array normalization
390389
request = (async () => {
390+
const slice = (await this.source.fetch([{ offset, length: byteCount }], signal))[0];
391391
let data = await poolOrDecoder.decode(this.fileDirectory, slice);
392392
const sampleFormat = this.getSampleFormat();
393393
const bitsPerSample = this.getBitsPerSample();
@@ -408,6 +408,11 @@ class GeoTIFFImage {
408408
// set the cache
409409
if (tiles !== null) {
410410
tiles[index] = request;
411+
request.catch(() => {
412+
if ( tiles[index] === request ) {
413+
tiles[index] = null;
414+
}
415+
});
411416
}
412417
} else {
413418
// get from the cache

0 commit comments

Comments
 (0)