@ultimat3/storage 31.19.0 → 31.21.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/storage",
3
- "version": "31.19.0",
3
+ "version": "31.21.0",
4
4
  "description": "Named disks over Bun.file and Bun.s3: safe keys, signed URLs, sniffed uploads",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -43,6 +43,6 @@
43
43
  "test": "bun test"
44
44
  },
45
45
  "dependencies": {
46
- "@ultimat3/core": "31.19.0"
46
+ "@ultimat3/core": "31.21.0"
47
47
  }
48
48
  }
@@ -133,14 +133,20 @@ export async function uploadInParts(input: MultipartUploadInput): Promise<Multip
133
133
  input.onProgress?.({ loaded: confirmed, total, ratio: total > 0 ? confirmed / total : 0 });
134
134
  };
135
135
 
136
+ // One failed part stops every worker taking another, and the upload answers only once the parts
137
+ // already in flight have settled: a caller that resumes on the failure never races a stale PUT.
138
+ let failure: { readonly error: unknown } | undefined;
136
139
  const worker = async (): Promise<void> => {
137
140
  for (let next = missing.shift(); next !== undefined; next = missing.shift()) {
138
- if (signal?.aborted === true) return;
139
- await sendPart(next);
141
+ if (signal?.aborted === true || failure !== undefined) return;
142
+ await sendPart(next).catch((error: unknown) => {
143
+ failure ??= { error };
144
+ });
140
145
  }
141
146
  };
142
147
  try {
143
148
  await Promise.all(Array.from({ length: Math.min(PART_CONCURRENCY, missing.length) }, worker));
149
+ if (failure !== undefined) throw failure.error;
144
150
  if (signal?.aborted === true) throw cancelled();
145
151
  } catch (error) {
146
152
  // Cancelled is abandoned: the parts are dropped now rather than billing until a sweep. Any