tardie 0.22.2-rc.262 → 0.22.2

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": "tardie",
3
- "version": "0.22.2-rc.262",
3
+ "version": "0.22.2",
4
4
  "license": "MIT",
5
5
  "author": "Clavia, Inc.",
6
6
  "description": "A durable agent harness. State is a pure function of the log.",
@@ -16,7 +16,7 @@
16
16
  "access": "public"
17
17
  },
18
18
  "tardigrade": {
19
- "sourceTree": "3eb7d0e3474deda5ebdef98d33656f132252564e"
19
+ "sourceTree": "51defd3cb83af555260546ac69a04a069a47c68f"
20
20
  },
21
21
  "files": [
22
22
  "src",
@@ -260,25 +260,23 @@ export class ThreadDO extends DurableObject<Env> {
260
260
  this.kick(host)
261
261
  }
262
262
 
263
- // kick starts reconciliation while the Durable Object is active and leaves its alarm armed until the host rests (test/actor.workers.ts, "a mounted actor exposes durable methods").
263
+ // kick retains each admission's drive through synchronization and releases at rest (tla/ActiveDrive.tla, AdmissionRetained and JoinedWorkDrained).
264
264
  private kick(host: CloudflareThreadHost): void {
265
- if (this.driving !== undefined) return
266
- let failed = false
267
- const driving = (async () => {
268
- try {
269
- await host.drive()
270
- await this.synchronizeAlarm(host)
271
- } catch (cause) {
272
- failed = true
273
- console.error("actor drive failed; the alarm remains armed", cause)
274
- }
275
- })()
276
- this.driving = driving
277
- retainBackgroundTask(this.ctx, this.backgroundTaskOwner, driving)
278
- void driving.finally(() => {
279
- if (this.driving === driving) this.driving = undefined
280
- if (!failed && host.work() > 0) this.kick(host)
281
- })
265
+ if (this.driving === undefined) {
266
+ this.driving = Promise.resolve().then(async () => {
267
+ try {
268
+ do {
269
+ await host.drive()
270
+ await this.synchronizeAlarm(host)
271
+ } while (host.work() > 0)
272
+ } catch (cause) {
273
+ console.error("actor drive failed; the alarm remains armed", cause)
274
+ } finally {
275
+ this.driving = undefined
276
+ }
277
+ })
278
+ }
279
+ retainBackgroundTask(this.ctx, this.backgroundTaskOwner, this.driving)
282
280
  }
283
281
 
284
282
  async append(thread: string, event: Event): Promise<boolean> {