-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(lambda-tiler): prevent unhandled promise rejections when the reje…
…ction is handled BM-1067 (#3329) ### Motivation Fetching data from remote services can and will error on occasion, the promises to fetch data from tiffs has two `.then()` one of the `.then()` has a associated `.catch()` the other does not, this leads to a `UnhandledPromiseRejection` ### Modifications Do not use a `.then()` without `.catch()` ### Verification Unit test addded. also checked the code base for more usages of `void ....then()` without .catch and they only occur in the landing page.
- Loading branch information
Showing
3 changed files
with
28 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import assert from 'node:assert'; | ||
import { describe, it } from 'node:test'; | ||
|
||
import { fsa, FsMemory } from '@chunkd/fs'; | ||
|
||
import { SourceCache } from '../source.cache.js'; | ||
|
||
describe('CoSourceCache', () => { | ||
it('should not exit if a promise rejection happens', async () => { | ||
const cache = new SourceCache(5); | ||
|
||
const mem = new FsMemory(); | ||
const tiffLoc = new URL('memory://foo/bar.tiff'); | ||
await mem.write(tiffLoc, Buffer.from('ABC123')); | ||
fsa.register('memory://', mem); | ||
|
||
await cache.getCog(tiffLoc).catch(() => null); | ||
assert.equal(cache.cache.currentSize, 1); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters