@steve31415/baselib 3.58.0 → 3.58.1

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.
@@ -61,6 +61,9 @@ export declare class HubDaemonClient {
61
61
  private minting;
62
62
  private mintFailures;
63
63
  private degradedSince;
64
+ /** now() when the last park answered `hint`: the hint behind it is
65
+ * already acted on, so no later lookback reaches back past it. */
66
+ private lastHintAt;
64
67
  constructor(opts: HubDaemonClientOptions);
65
68
  /** Begin the first mint in the background. Never throws. */
66
69
  start(): void;
@@ -58,6 +58,9 @@ export class HubDaemonClient {
58
58
  minting = null;
59
59
  mintFailures = 0;
60
60
  degradedSince = null;
61
+ /** now() when the last park answered `hint`: the hint behind it is
62
+ * already acted on, so no later lookback reaches back past it. */
63
+ lastHintAt = -Infinity;
61
64
  constructor(opts) {
62
65
  this.opts = opts;
63
66
  this.base = opts.hubUrl.replace(/\/$/, '');
@@ -95,7 +98,13 @@ export class HubDaemonClient {
95
98
  this.enterDegraded('no hub token');
96
99
  return this.degradedSleep(signal);
97
100
  }
98
- const lookback = Math.min(Math.max(0, Math.round(lookbackMs)) + HUB_LOOKBACK_SLACK_MS, HUB_LOOKBACK_MAX_MS);
101
+ // The lookback (review S2) covers the gap between the direct request and
102
+ // this park, but never reaches back past the previous `hint` answer: the
103
+ // hub still remembers that hint, and re-matching it would answer every
104
+ // park at once for the length of the lookback (a burst of direct
105
+ // requests, each a claim for Radar). Found by coder's integration test.
106
+ const sinceHint = Math.max(0, Math.floor(this.now() - this.lastHintAt));
107
+ const lookback = Math.min(Math.max(0, Math.round(lookbackMs)) + HUB_LOOKBACK_SLACK_MS, HUB_LOOKBACK_MAX_MS, sinceHint);
99
108
  const url = `${this.base}/api/daemon/wait?wait=${this.parkSeconds}&lookbackMs=${lookback}`;
100
109
  const bound = AbortSignal.timeout(this.parkSeconds * 1000 + HUB_PARK_CLIENT_SLACK_MS);
101
110
  const startedAt = this.now();
@@ -114,6 +123,7 @@ export class HubDaemonClient {
114
123
  }
115
124
  if (res.status === 200) {
116
125
  await res.json().catch(() => null);
126
+ this.lastHintAt = this.now();
117
127
  this.leaveDegraded();
118
128
  return 'hint';
119
129
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@steve31415/baselib",
3
- "version": "3.58.0",
3
+ "version": "3.58.1",
4
4
  "description": "Plasticine new-world shared platform library: logging, auth, service-to-service auth, db, HTTP, sync, app updates",
5
5
  "type": "module",
6
6
  "license": "MIT",