Skip to content

Commit 7702a29

Browse files
authored
external/s3: fix destroy() after zero requests (#1684)
Noted while working on getodk/central#1496 Closes getodk/central#1498
1 parent a7d8f8f commit 7702a29

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

lib/external/s3.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const init = (config) => {
2929
function destroy() {
3030
destroyed = true;
3131
return new Promise(resolve => {
32+
if (!inflight.size) return resolve(); // eslint-disable-line no-promise-executor-return
33+
3234
let remaining = 0;
3335
for (const req of inflight) {
3436
++remaining; // eslint-disable-line no-plusplus

test/unit/external/s3.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ describe('external/s3', () => {
5959
}
6060
});
6161

62+
describe('destroy()', () => {
63+
it('should resolve when no requests were made', async () => {
64+
// given
65+
const singleUseS3 = init(s3Config);
66+
67+
// expect
68+
should(await singleUseS3.destroy()).be.undefined();
69+
});
70+
});
71+
6272
describe('deleteObjsFor()', () => {
6373
it('should return details for upstream permission error', async () => {
6474
// given

0 commit comments

Comments
 (0)