@certik/skynet 0.14.0 → 0.15.1

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,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.15.1
4
+
5
+ - BREAKING: changed api restart behavior to never fail the allocation
6
+
7
+ ## 0.15.0
8
+
9
+ - BREAKING: only start one S3 client globally
10
+ - Fixed: Properly throw error if S3 client encounters them
11
+
3
12
  ## 0.14.0
4
13
 
5
14
  - BREAKING: only start one DynamoDB client globally
package/app.js CHANGED
@@ -46,7 +46,7 @@ async function checkDeployEnv(env) {
46
46
  }
47
47
 
48
48
  return { name: key, ok: true };
49
- })
49
+ }),
50
50
  );
51
51
 
52
52
  const missingEnvs = envStatus.filter((s) => !s.ok).map((s) => s.name);
@@ -694,8 +694,8 @@ function api({ name, routes, serve, beforeListen, env = {}, region = "us-east-1"
694
694
  restart: {
695
695
  attempts: 3,
696
696
  delay: "15s",
697
- mode: "fail",
698
- interval: "30m",
697
+ mode: "delay",
698
+ interval: "2m",
699
699
  },
700
700
  count: serve.instances,
701
701
  killTimeout: serve.killTimeout,
package/bun.lockb CHANGED
Binary file
package/deploy.js CHANGED
@@ -134,7 +134,8 @@ const genConfig = ({
134
134
  }
135
135
 
136
136
  restart {
137
- attempts = 0
137
+ attempts = 3
138
+ delay = "15s"
138
139
  mode = "fail"
139
140
  }
140
141
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@certik/skynet",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "description": "Skynet Shared JS library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -43,4 +43,4 @@
43
43
  "publishConfig": {
44
44
  "access": "public"
45
45
  }
46
- }
46
+ }
package/s3.js CHANGED
@@ -6,11 +6,17 @@ import {
6
6
  DeleteObjectCommand,
7
7
  ListObjectsV2Command,
8
8
  NotFound,
9
+ NoSuchKey,
9
10
  } from "@aws-sdk/client-s3";
10
11
  import { getAWSSDKConfig } from "./env.js";
11
12
 
12
- function getS3() {
13
- return new S3Client(getAWSSDKConfig());
13
+ let _s3Client;
14
+
15
+ function getS3(forceNew = false) {
16
+ if (!_s3Client || forceNew) {
17
+ _s3Client = new S3Client(getAWSSDKConfig());
18
+ }
19
+ return _s3Client;
14
20
  }
15
21
 
16
22
  async function readFile(bucketName, key, verbose = false) {
@@ -21,12 +27,16 @@ async function readFile(bucketName, key, verbose = false) {
21
27
  try {
22
28
  const result = await s3.send(new GetObjectCommand(params));
23
29
  return result.Body.transformToString();
24
- } catch (noSuchKeyErr) {
25
- if (verbose) {
26
- console.log("no such bucket or key", bucketName, key);
30
+ } catch (error) {
31
+ if (error instanceof NoSuchKey) {
32
+ if (verbose) {
33
+ console.log("no such bucket or key", bucketName, key);
34
+ }
35
+ // do nothing
36
+ return null;
27
37
  }
28
- // do nothing
29
- return null;
38
+
39
+ throw error;
30
40
  }
31
41
  }
32
42
 
@@ -93,10 +103,16 @@ async function deleteFile(bucketName, key, verbose = false) {
93
103
 
94
104
  try {
95
105
  await s3.send(new DeleteObjectCommand(params));
96
- } catch (noSuchKeyErr) {
97
- if (verbose) {
98
- console.log("no such bucket or key", bucketName, key);
106
+ } catch (error) {
107
+ if (error instanceof NoSuchKey) {
108
+ if (verbose) {
109
+ console.log("no such bucket or key", bucketName, key);
110
+ }
111
+ // do nothing
112
+ return null;
99
113
  }
114
+
115
+ throw error;
100
116
  }
101
117
  }
102
118