@wbce-d9/storage-driver-s3 10.0.4 → 10.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.test.js +13 -0
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -61,7 +61,7 @@ export class DriverS3 {
|
|
|
61
61
|
if (!stream || !isReadableStream(stream)) {
|
|
62
62
|
throw new Error(`No stream returned for file "${filepath}"`);
|
|
63
63
|
}
|
|
64
|
-
stream.
|
|
64
|
+
stream.once('close', () => client.destroy());
|
|
65
65
|
return stream;
|
|
66
66
|
}
|
|
67
67
|
async stat(filepath) {
|
package/dist/index.test.js
CHANGED
|
@@ -285,6 +285,19 @@ describe('#read', () => {
|
|
|
285
285
|
expect(driver['client'].send).toHaveBeenCalledWith(mockGetObjectCommand);
|
|
286
286
|
expect(stream).toBe(sample.stream);
|
|
287
287
|
});
|
|
288
|
+
test('Destroys the per-read S3 client when the stream is closed', async () => {
|
|
289
|
+
const stream = new Readable({ read() { } });
|
|
290
|
+
const client = {
|
|
291
|
+
send: vi.fn().mockResolvedValue({ Body: stream }),
|
|
292
|
+
destroy: vi.fn(),
|
|
293
|
+
};
|
|
294
|
+
vi.spyOn(driver, 'getClient').mockReturnValue(client);
|
|
295
|
+
await driver.read(sample.path.input);
|
|
296
|
+
const closed = new Promise((resolve) => stream.once('close', resolve));
|
|
297
|
+
stream.destroy();
|
|
298
|
+
await closed;
|
|
299
|
+
expect(client.destroy).toHaveBeenCalledOnce();
|
|
300
|
+
});
|
|
288
301
|
});
|
|
289
302
|
describe('#stat', () => {
|
|
290
303
|
beforeEach(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wbce-d9/storage-driver-s3",
|
|
3
|
-
"version": "10.0.
|
|
3
|
+
"version": "10.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "S3 file storage abstraction for `@wbce-d9/storage`",
|
|
6
6
|
"repository": {
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"@aws-sdk/client-s3": "3.1062.0",
|
|
29
29
|
"@aws-sdk/lib-storage": "3.1062.0",
|
|
30
30
|
"@wbce-d9/storage": "10.0.0",
|
|
31
|
-
"@wbce-d9/utils": "10.0.
|
|
31
|
+
"@wbce-d9/utils": "10.0.5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@ngneat/falso": "6.4.0",
|
|
35
35
|
"@types/node": "22.15.29",
|
|
36
|
-
"@vitest/coverage-v8": "4.1.
|
|
36
|
+
"@vitest/coverage-v8": "4.1.12",
|
|
37
37
|
"@wbce-d9/tsconfig": "2.0.0",
|
|
38
38
|
"typescript": "5.0.4",
|
|
39
|
-
"vitest": "4.1.
|
|
39
|
+
"vitest": "4.1.12"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsc --build",
|