Skip to content

Commit 3914e1b

Browse files
committed
fix(deploy): match decode-error signature on statusText, not body
The distilled client's CloudflareDecodeError sets body = JSON.stringify(rawBody): a JSON null body becomes "null" (matched the docs deploy) but an empty body becomes undefined (missed in the web deploy). status 200 + statusText "Schema decode failed" is the stable discriminator — it only ever marks a successful operation whose result failed to decode, which for a DELETE is a completed delete.
1 parent 5c49556 commit 3914e1b

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

apps/docs/alchemy.run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ const program = Effect.gen(function* () {
148148
Effect.catchTags({
149149
DomainNotFound: () => Effect.void,
150150
CloudflareHttpError: (e) =>
151-
e.status === 200 && e.body === "null"
151+
e.status === 200 && e.statusText === "Schema decode failed"
152152
? Effect.void
153153
: Effect.fail(e),
154154
}),

apps/web/alchemy.run.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ const program = Effect.gen(function* () {
143143
Effect.catchTags({
144144
DomainNotFound: () => Effect.void,
145145
CloudflareHttpError: (e) =>
146-
e.status === 200 && e.body === "null"
146+
e.status === 200 && e.statusText === "Schema decode failed"
147147
? Effect.void
148148
: Effect.fail(e),
149149
}),

patches/alchemy@2.0.0-beta.57.patch

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2
1010
diff --git a/node_modules/alchemy/.bun-tag-a8cf04031f0528ca b/.bun-tag-a8cf04031f0528ca
1111
new file mode 100644
1212
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
13+
diff --git a/node_modules/alchemy/.bun-tag-b4d075c85a3a57e7 b/.bun-tag-b4d075c85a3a57e7
14+
new file mode 100644
15+
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
1316
diff --git a/lib/Cloudflare/StateStore/Api.js b/lib/Cloudflare/StateStore/Api.js
1417
index 91cd6535c3ff5b8997764cd5c37a5a527f09a773..c60ded30c61681649df77d00f1b1e834095c93aa 100644
1518
--- a/lib/Cloudflare/StateStore/Api.js
@@ -68,7 +71,7 @@ index ff7b9a56c3795e13b833cf1ea6ece859c7896532..a7048956934ee531bd9ac6d14b66e911
6871
return {
6972
// -- Root DO methods -----------------------------------------
7073
diff --git a/lib/Cloudflare/Workers/Worker.js b/lib/Cloudflare/Workers/Worker.js
71-
index 912be17fdd1a0380471856b0c485a7f1a88dbc0b..b7624f18a4e42b5f4330771a71bf160ea4a29ff2 100644
74+
index 912be17fdd1a0380471856b0c485a7f1a88dbc0b..9bf422c05917ce23cc42c7f00550720c201898c6 100644
7275
--- a/lib/Cloudflare/Workers/Worker.js
7376
+++ b/lib/Cloudflare/Workers/Worker.js
7477
@@ -584,7 +584,15 @@ export const LiveWorkerProvider = () => Provider.effect(Worker, Effect.gen(funct
@@ -84,7 +87,7 @@ index 912be17fdd1a0380471856b0c485a7f1a88dbc0b..b7624f18a4e42b5f4330771a71bf160e
8487
+ // client. The delete DID happen server-side, so swallow exactly
8588
+ // that signature; every other status (403/409/5xx/404) still
8689
+ // fails the deploy.
87-
+ .pipe(Effect.catchTags({ DomainNotFound: () => Effect.void, CloudflareHttpError: (e) => e.status === 200 && e.body === "null" ? Effect.void : Effect.fail(e) }))), { concurrency: "unbounded" });
90+
+ .pipe(Effect.catchTags({ DomainNotFound: () => Effect.void, CloudflareHttpError: (e) => e.status === 200 && e.statusText === "Schema decode failed" ? Effect.void : Effect.fail(e) }))), { concurrency: "unbounded" });
8891
if (desired.length === 0)
8992
return [];
9093
const zoneCache = new Map();
@@ -93,7 +96,7 @@ index 912be17fdd1a0380471856b0c485a7f1a88dbc0b..b7624f18a4e42b5f4330771a71bf160e
9396
domainId: d.id,
9497
})
9598
- .pipe(Effect.catchTag("DomainNotFound", () => Effect.void)),
96-
+ .pipe(Effect.catchTags({ DomainNotFound: () => Effect.void, CloudflareHttpError: (e) => e.status === 200 && e.body === "null" ? Effect.void : Effect.fail(e) })),
99+
+ .pipe(Effect.catchTags({ DomainNotFound: () => Effect.void, CloudflareHttpError: (e) => e.status === 200 && e.statusText === "Schema decode failed" ? Effect.void : Effect.fail(e) })),
97100
]
98101
: []), { concurrency: "unbounded" });
99102
}

0 commit comments

Comments
 (0)