@empiricalrun/r2-uploader 0.1.0 → 0.1.2

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,17 @@
1
1
  # @empiricalrun/r2-uploader
2
2
 
3
+ ## 0.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 7a51a93: fix: upload individual attachments per test and add logs
8
+
9
+ ## 0.1.1
10
+
11
+ ### Patch Changes
12
+
13
+ - 51b7e11: fix: clean up r2 uploader logs
14
+
3
15
  ## 0.1.0
4
16
 
5
17
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,UAAU,OAAO;IACf,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AA+HD,wBAAsB,eAAe,CAAC,EACpC,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,SAAS,EACT,WAAW,EACX,eAAe,GAChB,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,OAAO,CAAC,CAYnB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAuBA,UAAU,OAAO;IACf,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB;AA2ID,wBAAsB,eAAe,CAAC,EACpC,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,SAAS,EACT,WAAW,EACX,eAAe,GAChB,EAAE;IACD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GAAG,OAAO,CAAC,OAAO,CAAC,CAYnB"}
package/dist/index.js CHANGED
@@ -69,6 +69,7 @@ const run = async (config) => {
69
69
  files = getFileList(config.sourceDir);
70
70
  }
71
71
  await Promise.all(files.map(async (file) => {
72
+ // console.log("\nStarting file upload for : ", file);
72
73
  const fileStream = fs.readFileSync(file);
73
74
  const fileName = file.replace(config.sourceDir, "");
74
75
  const fileKey = path_1.default.join(config.destinationDir !== "" ? config.destinationDir : config.sourceDir, fileName);
@@ -102,20 +103,24 @@ const run = async (config) => {
102
103
  try {
103
104
  await (0, async_retry_1.default)(async () => {
104
105
  try {
106
+ console.log("\n\nStarting file upload for: ", file, "\n\n");
105
107
  const data = await S3.send(cmd);
106
108
  // console.log(`R2 Success - ${file}`);
107
109
  map.set(file, data);
108
110
  const fileUrl = await (0, s3_request_presigner_1.getSignedUrl)(S3, cmd);
109
111
  urls[file] = fileUrl;
112
+ console.log("\n\nFinished file upload for: ", file, "\n\n");
110
113
  }
111
114
  catch (err) {
115
+ console.log("\n\nError uploading file: ", file, err, "\n\n");
112
116
  const error = err;
113
117
  if (error["$metadata"]) {
118
+ // throw only those errors that are not 412 Precondition Failed
119
+ // 412 errors are errors while accessing the asset, which is post upload and can be ignored
114
120
  if (error.$metadata.httpStatusCode !== 412) {
115
121
  throw error;
116
122
  }
117
123
  }
118
- console.log("Error which is not retried", error);
119
124
  }
120
125
  }, {
121
126
  retries: 5,
@@ -123,6 +128,13 @@ const run = async (config) => {
123
128
  minTimeout: 1000,
124
129
  maxTimeout: 60000,
125
130
  randomize: true,
131
+ onRetry: (err, i) => {
132
+ if (err) {
133
+ const error = err;
134
+ console.log("Upload retry attempt:", i, ":", file);
135
+ console.log("Response status:", error.$response?.statusCode);
136
+ }
137
+ },
126
138
  });
127
139
  }
128
140
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/r2-uploader",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"