byollm 0.1.0-alpha.78 → 0.1.0-alpha.79

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  > [!WARNING]
2
- > **Alpha (`0.1.0-alpha.78`) — under active development. Don't use this yet.**
2
+ > **Alpha (`0.1.0-alpha.79`) — under active development. Don't use this yet.**
3
3
  >
4
4
  > Install it deliberately: `npx byollm@alpha`, or `npm install byollm@alpha`.
5
5
  >
package/dist/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  main
4
- } from "./chunk-ZROCDZDA.js";
4
+ } from "./chunk-F4USGV52.js";
5
5
 
6
6
  // src/bin.ts
7
7
  process.exitCode = await main(process.argv.slice(2));
@@ -3598,6 +3598,8 @@ function joinSections(sections) {
3598
3598
  }
3599
3599
 
3600
3600
  // src/runner.ts
3601
+ var FETCH_ATTEMPTS_BEFORE_GONE = 3;
3602
+ var GAVE_UP_TTL_MS = 10 * 6e4;
3601
3603
  var AUTH_RECHECK_MS = 6e4;
3602
3604
  var DEFAULT_HEARTBEAT_MS = 1e4;
3603
3605
  function sameKey(a, b) {
@@ -3671,6 +3673,14 @@ var Runner = class {
3671
3673
  #withdrawnReport = /* @__PURE__ */ new Map();
3672
3674
  /** Earliest moment each withdrawn service may be asked again — T2-S1. */
3673
3675
  #authRecheckAt = /* @__PURE__ */ new Map();
3676
+ /**
3677
+ * Jobs whose payload this device could not fetch, and how often.
3678
+ *
3679
+ * Bounded by pruning on use: an entry only matters while the job it names
3680
+ * could still be offered again, and a daemon that met one bad job a year
3681
+ * ago should not still be carrying it.
3682
+ */
3683
+ #gaveUpFetching = /* @__PURE__ */ new Map();
3674
3684
  /** What was last handed to the writer, so an unchanged pass writes nothing. */
3675
3685
  #lastWritten;
3676
3686
  /**
@@ -4589,10 +4599,22 @@ var Runner = class {
4589
4599
  const fetched = await this.#fetchWhenSealed(job);
4590
4600
  if (!fetched) return;
4591
4601
  if ("gone" in fetched) {
4602
+ for (const [id, entry] of this.#gaveUpFetching) {
4603
+ if (this.#now() - entry.at > GAVE_UP_TTL_MS) {
4604
+ this.#gaveUpFetching.delete(id);
4605
+ }
4606
+ }
4607
+ const seen = this.#gaveUpFetching.get(job.id);
4608
+ const attempts = (seen?.attempts ?? 0) + 1;
4609
+ this.#gaveUpFetching.set(job.id, { attempts, at: this.#now() });
4592
4610
  this.#options.onEvent?.({
4593
4611
  type: "error",
4594
- message: `${job.id} is not ours to run: ${fetched.gone}`
4612
+ message: `could not fetch ${job.id} (${fetched.gone}) \u2014 attempt ${String(attempts)} of ${String(FETCH_ATTEMPTS_BEFORE_GONE)}`
4595
4613
  });
4614
+ if (attempts < FETCH_ATTEMPTS_BEFORE_GONE) {
4615
+ return;
4616
+ }
4617
+ this.#gaveUpFetching.delete(job.id);
4596
4618
  await this.#safely(
4597
4619
  () => this.#options.client.release({
4598
4620
  runnerId: this.#options.runnerId,
@@ -4602,6 +4624,7 @@ var Runner = class {
4602
4624
  );
4603
4625
  return;
4604
4626
  }
4627
+ this.#gaveUpFetching.delete(job.id);
4605
4628
  const payload = await this.#openPayload(job, fetched.envelope);
4606
4629
  const resolved = job.grant?.service;
4607
4630
  const route = this.#routeFor(job.kind, resolved);
@@ -7116,7 +7139,7 @@ async function exists(path) {
7116
7139
  }
7117
7140
 
7118
7141
  // src/index.ts
7119
- var DAEMON_VERSION = "0.1.0-alpha.78";
7142
+ var DAEMON_VERSION = "0.1.0-alpha.79";
7120
7143
  function daemonVersion() {
7121
7144
  return {
7122
7145
  daemon: DAEMON_VERSION,
@@ -7168,4 +7191,4 @@ export {
7168
7191
  runCli,
7169
7192
  main
7170
7193
  };
7171
- //# sourceMappingURL=chunk-ZROCDZDA.js.map
7194
+ //# sourceMappingURL=chunk-F4USGV52.js.map