@wbce-d9/storage-driver-s3 10.0.5 → 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 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.on('finished', () => client.destroy());
64
+ stream.once('close', () => client.destroy());
65
65
  return stream;
66
66
  }
67
67
  async stat(filepath) {
@@ -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.5",
3
+ "version": "10.0.6",
4
4
  "type": "module",
5
5
  "description": "S3 file storage abstraction for `@wbce-d9/storage`",
6
6
  "repository": {
@@ -33,10 +33,10 @@
33
33
  "devDependencies": {
34
34
  "@ngneat/falso": "6.4.0",
35
35
  "@types/node": "22.15.29",
36
- "@vitest/coverage-v8": "4.1.11",
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.11"
39
+ "vitest": "4.1.12"
40
40
  },
41
41
  "scripts": {
42
42
  "build": "tsc --build",