From 092ce92eb2df9b7c5cf0c79a01aca1c94e8f5d09 Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot <318394648+systemfsoftware-bot@users.noreply.github.com> Date: Thu, 26 Nov 2026 13:37:42 -0500 Subject: [PATCH 1/3] fix(platform-cloudflare): awaitProgress re-issues after a transient reset A Durable Object reset reaches the waiting client as a plain remote rejection, an overload-flagged rejection, or an answer that cannot be decoded, not only as a rejection flagged as a reset. The wait observes durable state, so every such transport failure leaves the attempt with nothing observed and the same attempt budget can re-issue it; typed host failures stay terminal. Without this, the client wait ended on the reset and no subscription reached the fresh incarnation, so a caller awaiting progress never saw it reconnect. The eviction test now races the reconstructed-waiter latch against the client wait's join, so a client wait that ends early surfaces its own error instead of parking until the test cap. Timeout, assertions and the attempt budget are unchanged. --- .changeset/await-progress-reconnect.md | 5 ++++ .../src/CloudflareThreadClient.ts | 29 +++++++++++++------ .../test/progress-wait.test.ts | 11 ++++--- 3 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 .changeset/await-progress-reconnect.md diff --git a/.changeset/await-progress-reconnect.md b/.changeset/await-progress-reconnect.md new file mode 100644 index 00000000..e09f1c8f --- /dev/null +++ b/.changeset/await-progress-reconnect.md @@ -0,0 +1,5 @@ +--- +"@systemfsoftware/agent-platform-cloudflare": patch +--- + +`CloudflareThreadClient.awaitProgress` now re-issues its wait after any transient transport failure, so a wait for durable progress survives a Durable Object reset instead of ending with the reset's error. diff --git a/packages/platform-cloudflare/src/CloudflareThreadClient.ts b/packages/platform-cloudflare/src/CloudflareThreadClient.ts index edf9ce61..6a779e44 100644 --- a/packages/platform-cloudflare/src/CloudflareThreadClient.ts +++ b/packages/platform-cloudflare/src/CloudflareThreadClient.ts @@ -875,21 +875,32 @@ export class CloudflareThreadClient extends Context.Service< ), ) + // Waiting for progress observes durable state, so a transport failure means this + // attempt observed nothing and the same attempt budget may re-issue it. A reset + // reaches the caller in several shapes — the reset-flagged rejection, a bare remote + // rejection, an overload-flagged rejection, or an answer cut off mid-write that + // cannot be decoded — so every transport failure re-issues, while a typed host + // failure (a real domain outcome) stays terminal. + const reissue = ( + error: ThreadClientError | HostProtocolError, + retry: number, + ): Effect.Effect => + retry < 5 + ? Effect.sleep(Duration.millis(10 * 2 ** retry)).pipe( + Effect.andThen(attempt(retry + 1)), + ) + : Effect.fail(error) + const attempt = (retry: number): Effect.Effect => call(threadId, 'awaitProgress', encoded).pipe( Effect.flatMap( expect(threadId, 'awaitProgress', ProgressObserved, ClientObserveHostFailure), ), Effect.asVoid, - Effect.catchTag( - 'ThreadClientError', - (error) => - error.retryable === true && error.overloaded !== true && retry < 5 - ? Effect.sleep(Duration.millis(10 * 2 ** retry)).pipe( - Effect.andThen(attempt(retry + 1)), - ) - : Effect.fail(error), - ), + Effect.catchTags({ + ThreadClientError: (error) => reissue(error, retry), + HostProtocolError: (error) => reissue(error, retry), + }), ) yield* attempt(0).pipe(Effect.onInterrupt(() => cancelProgress(threadId, waiterId))) diff --git a/packages/platform-cloudflare/test/progress-wait.test.ts b/packages/platform-cloudflare/test/progress-wait.test.ts index cfdf20f8..67dcf215 100644 --- a/packages/platform-cloudflare/test/progress-wait.test.ts +++ b/packages/platform-cloudflare/test/progress-wait.test.ts @@ -161,10 +161,13 @@ describe('#94 Cloudflare durable progress wait', () => { state.abort('#94 forced wait eviction') }).catch(() => undefined) - const reconstructedIncarnation = await awaitReconstructedProgressWaiter( - thread, - priorIncarnation, - 1, + const surfaceClientWaitFailure = Fiber.join(waiting).pipe(Effect.flatMap(() => Effect.never)) + + const reconstructedIncarnation = await Effect.runPromise( + Effect.raceFirst( + Effect.promise(() => awaitReconstructedProgressWaiter(thread, priorIncarnation, 1)), + surfaceClientWaitFailure, + ), ) expect(reconstructedIncarnation).not.toBe(priorIncarnation) From 2db6bf166bf171e2549c3a566cc66cfe4f98a66d Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot <318394648+systemfsoftware-bot@users.noreply.github.com> Date: Thu, 26 Nov 2026 13:42:28 -0500 Subject: [PATCH 2/3] fix(platform-cloudflare): leave an overload-flagged reset rejection terminal The wait re-issued every transport failure, including one the runtime flagged as overloaded. That shape is marked as not worth retrying because a retry adds load to an object that cannot keep up, so it stays terminal; the bare remote rejection of a reset and an answer that cannot be decoded still re-issue. --- .changeset/await-progress-reconnect.md | 2 +- .../platform-cloudflare/src/CloudflareThreadClient.ts | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.changeset/await-progress-reconnect.md b/.changeset/await-progress-reconnect.md index e09f1c8f..afd5ba9c 100644 --- a/.changeset/await-progress-reconnect.md +++ b/.changeset/await-progress-reconnect.md @@ -2,4 +2,4 @@ "@systemfsoftware/agent-platform-cloudflare": patch --- -`CloudflareThreadClient.awaitProgress` now re-issues its wait after any transient transport failure, so a wait for durable progress survives a Durable Object reset instead of ending with the reset's error. +`CloudflareThreadClient.awaitProgress` now re-issues its wait when a reset reaches it as a bare remote rejection or as an answer that cannot be decoded, so a wait for durable progress survives a Durable Object reset instead of ending with the reset's error. diff --git a/packages/platform-cloudflare/src/CloudflareThreadClient.ts b/packages/platform-cloudflare/src/CloudflareThreadClient.ts index 6a779e44..8f005e91 100644 --- a/packages/platform-cloudflare/src/CloudflareThreadClient.ts +++ b/packages/platform-cloudflare/src/CloudflareThreadClient.ts @@ -875,12 +875,6 @@ export class CloudflareThreadClient extends Context.Service< ), ) - // Waiting for progress observes durable state, so a transport failure means this - // attempt observed nothing and the same attempt budget may re-issue it. A reset - // reaches the caller in several shapes — the reset-flagged rejection, a bare remote - // rejection, an overload-flagged rejection, or an answer cut off mid-write that - // cannot be decoded — so every transport failure re-issues, while a typed host - // failure (a real domain outcome) stays terminal. const reissue = ( error: ThreadClientError | HostProtocolError, retry: number, @@ -898,7 +892,7 @@ export class CloudflareThreadClient extends Context.Service< ), Effect.asVoid, Effect.catchTags({ - ThreadClientError: (error) => reissue(error, retry), + ThreadClientError: (error) => error.overloaded === true ? Effect.fail(error) : reissue(error, retry), HostProtocolError: (error) => reissue(error, retry), }), ) From 0afc585ca000bd6c9f4db762441f8ffb8811b6b1 Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot <318394648+systemfsoftware-bot@users.noreply.github.com> Date: Thu, 26 Nov 2026 13:45:24 -0500 Subject: [PATCH 3/3] docs(solutions): a reset rejects the in-flight wait and the client re-issues it The solution doc said an in-flight awaitProgress call survives state.abort() and is replayed on the fresh incarnation, so the client's retry never runs. Measured otherwise: the reset rejects the call with remote and durableObjectReset set, and workerd does not replay it, which is why the client re-issues and why a test that waits for the fresh incarnation's subscription stalls when that re-issue does not happen. --- ...test-work-outlives-the-workerd-environment.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/solutions/test-failures/cross-object-test-work-outlives-the-workerd-environment.md b/docs/solutions/test-failures/cross-object-test-work-outlives-the-workerd-environment.md index 0f9e8d5e..050c1301 100644 --- a/docs/solutions/test-failures/cross-object-test-work-outlives-the-workerd-environment.md +++ b/docs/solutions/test-failures/cross-object-test-work-outlives-the-workerd-environment.md @@ -31,10 +31,11 @@ it runs, and the budget is the suite's configured `testTimeout`, not the machine 135 sequential SQLite operations plus a cold reconstruction, so 10 s was below what the work needs when the CPUs are shared. -Measured with a probe: an in-flight `awaitProgress` RPC is not rejected by `state.abort()`. Workerd -re-runs the request on the fresh incarnation, the fresh incarnation reports the waiter, and the -client promise resolves when progress arrives. The client's retry classification therefore never -runs for an eviction. +Measured with a probe: `state.abort()` rejects an in-flight `awaitProgress` RPC with an error +carrying `remote` and `durableObjectReset` (200/200 on a plain RPC, 160/160 through the client), and +workerd does not replay the request on the fresh incarnation. The client therefore has to re-issue +it, and a test that waits for the fresh incarnation to report a subscription stalls for its whole cap +whenever that re-issue does not happen. ## What does not work @@ -48,8 +49,11 @@ runs for an eviction. ## What works -- Count subscriptions monotonically per incarnation, so a replay is observed whether or not it is - still parked, and latch on the count rather than on a gauge. +- Re-issue the wait from the client after a reset-shaped transport failure (a bare remote rejection + or an answer that cannot be decoded), and keep an overload-flagged rejection and a typed host + failure terminal. +- Count subscriptions monotonically per incarnation, so a re-issued request is observed whether or + not it is still parked, and latch on the count rather than on a gauge. - Fork client work through a harness that tracks every fiber, and interrupt and await them after each test instead of at the end of the file. - After each test, disarm the eviction failpoints it armed and delete the persisted alarm of every