@vzn/vx-cache 0.0.648 → 0.0.650

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.
Files changed (3) hide show
  1. package/README.md +3 -0
  2. package/package.json +2 -2
  3. package/src/index.ts +19 -10
package/README.md CHANGED
@@ -83,6 +83,9 @@ workflow would carry a token that writes nowhere the run reads. A job
83
83
  uses a lent token over its own and never lends one on, nor any once
84
84
  its remote is off for the run.
85
85
 
86
+ An upload answered with a 5xx or a 429 is sent again, three tries in
87
+ all: a PUT names its hash, so a second one stores the same bytes.
88
+
86
89
  A refused token is said once and turns the remote off for the run; a
87
90
  refused write (a job that reads only) turns off writes alone. Any other
88
91
  refusal is a warning naming the server's own words, and the task reads
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vzn/vx-cache",
3
- "version": "0.0.648",
3
+ "version": "0.0.650",
4
4
  "license": "MIT",
5
5
  "description": "vxCache(): a vx cache plugin for a server that speaks the vx-cache protocol, such as @vzn/vx-cache-server.",
6
6
  "keywords": [
@@ -32,7 +32,7 @@
32
32
  "jose: the tests sign the CI tokens the server checks."
33
33
  ],
34
34
  "peerDependencies": {
35
- "@vzn/vx": "^0.0.648"
35
+ "@vzn/vx": "^0.0.650"
36
36
  },
37
37
  "repository": {
38
38
  "type": "git",
package/src/index.ts CHANGED
@@ -800,16 +800,25 @@ export class VxCacheLayer implements RemoteCacheLayer {
800
800
  private async upload(item: { hash: string; body: Blob }): Promise<void | false> {
801
801
  // Queued before the remote or its writes were turned off.
802
802
  if (this.disabled || this.writesRefused) return false
803
- const res = await this.request(`/v1/artifacts/${item.hash}`, {
804
- method: 'PUT',
805
- body: item.body,
806
- headers: { 'content-type': 'application/octet-stream' },
807
- timeoutMs: this.config.uploadTimeoutMs,
808
- write: true,
809
- paced: true,
810
- })
811
- if (res === undefined) return false
812
- if (!res.ok) throw await refusal(res)
803
+ // Sent again after a 5xx or a 429, up to three tries, as the token's ask:
804
+ // the server failing to read GitHub's keys once lost a DTE worker's entry
805
+ // (2026-10-29). A PUT names its hash, so a second one stores the same bytes.
806
+ for (let attempt = 1; ; attempt++) {
807
+ const res = await this.request(`/v1/artifacts/${item.hash}`, {
808
+ method: 'PUT',
809
+ body: item.body,
810
+ headers: { 'content-type': 'application/octet-stream' },
811
+ timeoutMs: this.config.uploadTimeoutMs,
812
+ write: true,
813
+ paced: true,
814
+ })
815
+ if (res === undefined) return false
816
+ if (res.ok) return
817
+ if ((res.status !== 429 && res.status < 500) || attempt === ASK_ATTEMPTS)
818
+ throw await refusal(res)
819
+ await res.body?.cancel()
820
+ await this.wait(1000 * attempt)
821
+ }
813
822
  }
814
823
  }
815
824