@adobe/helix-admin-support 1.3.11 → 1.3.12

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/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.3.12](https://github.com/adobe/helix-admin-support/compare/v1.3.11...v1.3.12) (2022-09-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * destroy S3Client after use; use timeout for S3 fetch ([378bb37](https://github.com/adobe/helix-admin-support/commit/378bb37fd2603f59fc6886db4c928f2b4e1cbb7b))
7
+
1
8
  ## [1.3.11](https://github.com/adobe/helix-admin-support/compare/v1.3.10...v1.3.11) (2022-09-24)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adobe/helix-admin-support",
3
- "version": "1.3.11",
3
+ "version": "1.3.12",
4
4
  "description": "Helix Admin Support Library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -34,7 +34,8 @@
34
34
  "@adobe/fetch": "3.1.4",
35
35
  "@adobe/helix-shared-config": "9.1.1",
36
36
  "@adobe/helix-shared-utils": "2.1.0",
37
- "@aws-sdk/client-s3": "3.178.0"
37
+ "@aws-sdk/client-s3": "3.178.0",
38
+ "@aws-sdk/node-http-handler": "3.178.0"
38
39
  },
39
40
  "devDependencies": {
40
41
  "@adobe/eslint-config-helix": "1.3.2",
package/src/fetch-s3.js CHANGED
@@ -18,6 +18,7 @@ import {
18
18
  HeadObjectCommand,
19
19
  NoSuchKey,
20
20
  } from '@aws-sdk/client-s3';
21
+ import { NodeHttpHandler } from '@aws-sdk/node-http-handler';
21
22
 
22
23
  const gunzip = promisify(zlib.gunzip);
23
24
 
@@ -38,6 +39,11 @@ export async function fetchS3(context, bucketId, key, head = false) {
38
39
  }
39
40
  const { log, env = {} } = context;
40
41
 
42
+ const {
43
+ HELIX_HTTP_CONNECTION_TIMEOUT = 5000,
44
+ HELIX_HTTP_SOCKET_TIMEOUT = 15000,
45
+ } = env;
46
+
41
47
  try {
42
48
  // the client initialization is a bit picky with undefined properties.
43
49
  // so we omit the credentials when we provide them via context.env
@@ -48,14 +54,23 @@ export async function fetchS3(context, bucketId, key, head = false) {
48
54
  accessKeyId: env.AWS_S3_ACCESS_KEY_ID,
49
55
  secretAccessKey: env.AWS_S3_SECRET_ACCESS_KEY,
50
56
  },
57
+ requestHandler: new NodeHttpHandler({
58
+ connectionTimeout: HELIX_HTTP_CONNECTION_TIMEOUT,
59
+ socketTimeout: HELIX_HTTP_SOCKET_TIMEOUT,
60
+ }),
51
61
  };
52
62
  const s3 = new S3Client(opts);
53
63
  const Command = head ? HeadObjectCommand : GetObjectCommand;
54
- const res = await s3.send(new Command({
55
- Bucket: bucketId,
56
- Key: key,
57
- // todo: add timeout
58
- }));
64
+ let res;
65
+ try {
66
+ res = await s3.send(new Command({
67
+ Bucket: bucketId,
68
+ Key: key,
69
+ // todo: add timeout
70
+ }));
71
+ } finally {
72
+ s3.destroy();
73
+ }
59
74
 
60
75
  let buffer = '';
61
76
  if (!head) {