byollm 0.1.0-alpha.4 → 0.1.0-alpha.6
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/README.md +1 -1
- package/dist/bin.js +1 -1
- package/dist/{chunk-CKWS6NEW.js → chunk-EU4PO36M.js} +50 -8
- package/dist/chunk-EU4PO36M.js.map +1 -0
- package/dist/index.d.ts +11 -2
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-CKWS6NEW.js.map +0 -1
package/README.md
CHANGED
package/dist/bin.js
CHANGED
|
@@ -220,7 +220,7 @@ var ClientError = class extends Error {
|
|
|
220
220
|
name = "ClientError";
|
|
221
221
|
/** Is retrying this same call plausibly useful? */
|
|
222
222
|
get retryable() {
|
|
223
|
-
return this.kind === "unreachable" || this.kind === "rate-limited" || this.kind === "server-error";
|
|
223
|
+
return this.kind === "unreachable" || this.kind === "not-ready" || this.kind === "rate-limited" || this.kind === "server-error";
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
226
|
var DEFAULT_TIMEOUT_MS = 3e4;
|
|
@@ -383,6 +383,8 @@ var ProtocolClient = class _ProtocolClient {
|
|
|
383
383
|
return new ClientError("unauthorized", message, retryAfter);
|
|
384
384
|
case 403:
|
|
385
385
|
return new ClientError("revoked", message, retryAfter);
|
|
386
|
+
case 409:
|
|
387
|
+
return new ClientError("not-ready", message, retryAfter);
|
|
386
388
|
case 429:
|
|
387
389
|
return new ClientError("rate-limited", message, retryAfter);
|
|
388
390
|
case 400:
|
|
@@ -2141,11 +2143,8 @@ var Runner = class {
|
|
|
2141
2143
|
);
|
|
2142
2144
|
return;
|
|
2143
2145
|
}
|
|
2144
|
-
const fetched = await this.#
|
|
2145
|
-
|
|
2146
|
-
jobId: job.id,
|
|
2147
|
-
leaseId: job.lease.id
|
|
2148
|
-
});
|
|
2146
|
+
const fetched = await this.#fetchWhenSealed(job);
|
|
2147
|
+
if (!fetched) return;
|
|
2149
2148
|
const payload = await this.#openPayload(job, fetched.envelope);
|
|
2150
2149
|
const route = this.#routeFor(job.kind);
|
|
2151
2150
|
const outcome = await this.runJob({ ...job, payload });
|
|
@@ -2194,6 +2193,49 @@ var Runner = class {
|
|
|
2194
2193
|
}
|
|
2195
2194
|
});
|
|
2196
2195
|
}
|
|
2196
|
+
/**
|
|
2197
|
+
* Collect the payload, waiting if the upstream does not have it yet.
|
|
2198
|
+
*
|
|
2199
|
+
* On the direct plane this always succeeds first time: the site *is* the
|
|
2200
|
+
* upstream, so it seals when asked. Through a relay the two are different
|
|
2201
|
+
* parties — the site must be told which device claimed before it can seal to
|
|
2202
|
+
* it — and `not-ready` is a normal answer for as long as that takes.
|
|
2203
|
+
*
|
|
2204
|
+
* Discovered by the skeleton relay, which is the reason it exists: the
|
|
2205
|
+
* original claim-then-fetch had no wait here, so the first relayed job was
|
|
2206
|
+
* claimed, refused with a 409 the daemon treated as a rejection, and
|
|
2207
|
+
* abandoned while still holding a perfectly good lease.
|
|
2208
|
+
*
|
|
2209
|
+
* Bounded, and by the lease rather than by a retry count: waiting past our
|
|
2210
|
+
* own lease means racing whoever gets the job next. Returning `null` gives
|
|
2211
|
+
* the job up quietly — the upstream's `awaiting-payload` timer will requeue
|
|
2212
|
+
* it, and the stub was never lost.
|
|
2213
|
+
*/
|
|
2214
|
+
async #fetchWhenSealed(job) {
|
|
2215
|
+
const deadline = Math.min(job.lease.expiresAt, this.#now() + 3e4);
|
|
2216
|
+
let delay = 50;
|
|
2217
|
+
for (; ; ) {
|
|
2218
|
+
try {
|
|
2219
|
+
return await this.#options.client.fetch({
|
|
2220
|
+
runnerId: this.#options.runnerId,
|
|
2221
|
+
jobId: job.id,
|
|
2222
|
+
leaseId: job.lease.id
|
|
2223
|
+
});
|
|
2224
|
+
} catch (error) {
|
|
2225
|
+
const notReady = error instanceof ClientError && error.kind === "not-ready";
|
|
2226
|
+
if (!notReady) throw error;
|
|
2227
|
+
if (this.#now() + delay >= deadline) {
|
|
2228
|
+
this.#options.onEvent?.({
|
|
2229
|
+
type: "error",
|
|
2230
|
+
message: `gave up waiting for the payload of ${job.id}`
|
|
2231
|
+
});
|
|
2232
|
+
return null;
|
|
2233
|
+
}
|
|
2234
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
2235
|
+
delay = Math.min(delay * 2, 1e3);
|
|
2236
|
+
}
|
|
2237
|
+
}
|
|
2238
|
+
}
|
|
2197
2239
|
/**
|
|
2198
2240
|
* Open work sealed to this machine, or refuse to run it.
|
|
2199
2241
|
*
|
|
@@ -2991,7 +3033,7 @@ async function main(argv) {
|
|
|
2991
3033
|
}
|
|
2992
3034
|
|
|
2993
3035
|
// src/index.ts
|
|
2994
|
-
var DAEMON_VERSION = "0.1.0-alpha.
|
|
3036
|
+
var DAEMON_VERSION = "0.1.0-alpha.6";
|
|
2995
3037
|
function daemonVersion() {
|
|
2996
3038
|
return {
|
|
2997
3039
|
daemon: DAEMON_VERSION,
|
|
@@ -3044,4 +3086,4 @@ export {
|
|
|
3044
3086
|
runCli,
|
|
3045
3087
|
main
|
|
3046
3088
|
};
|
|
3047
|
-
//# sourceMappingURL=chunk-
|
|
3089
|
+
//# sourceMappingURL=chunk-EU4PO36M.js.map
|