Skip to content

Add Cloudflare Durable Objects backend - #36

Merged
cardmagic merged 10 commits into
mainfrom
feat/cloudflare-durable-objects-backend
Sep 5, 2026
Merged

Add Cloudflare Durable Objects backend#36
cardmagic merged 10 commits into
mainfrom
feat/cloudflare-durable-objects-backend

Conversation

@cardmagic

Copy link
Copy Markdown
Owner

Summary

  • add a portable solid-objects/core API and Cloudflare Durable Objects runtime backend
  • add durable actor mailboxes, retries, reminders, effects, outboxes, migrations, recovery, and incarnation fencing
  • add hibernating session Durable Objects for multiplexed browser realtime subscriptions
  • add a runnable Wrangler example, Cloudflare capability documentation, parity notes, and CI/package checks
  • preserve explicit unsupported boundaries for shared SQL transactions, fleet administration, and process-local server realtime

Validation

  • pnpm test — 366 passed, 17 skipped
  • pnpm run test:cloudflare — 34 passed
  • pnpm run test:browser — 9 passed
  • pnpm run check
  • pnpm run check:cloudflare
  • pnpm run test:package
  • pnpm audit --audit-level=high
  • local Wrangler HTTP/WebSocket/alarm/restart persistence smoke test

The Cloudflare backend is documented as experimental pending a deployed failover/soak test. No production deployment or DNS changes are included.

@greptile-apps

greptile-apps Bot commented Sep 5, 2026

Copy link
Copy Markdown

Greptile Summary

The latest revision completes the previously requested fixes and release preparation for the Cloudflare Durable Objects backend.

  • Validates accumulated cart quantities before persisting them and adds a regression test.
  • Replaces the reviewed unknown annotations in Cloudflare runtime helpers.
  • Adds source aliases needed by Cloudflare type-checking.
  • Aligns the package, runtime constant, and changelog at version 0.14.7.
  • All four previous review threads are resolved; no new actionable regression was identified.

Confidence Score: 5/5

The latest revision appears safe to merge, with all previous threads resolved and no newly introduced actionable defect identified.

The accumulated-quantity fix rejects unsafe totals before mutation, the updated helper typings preserve existing runtime validation and error handling, and release metadata is consistent. All four prior findings were manually resolved without explanatory replies; the latest quantity change also directly addresses its prior precision finding.

Important Files Changed

Filename Overview
examples/cloudflare/shopping-cart.ts Safely validates the accumulated item quantity before mutating cart state.
test/cloudflare/example.test.ts Adds focused regression coverage for quantity accumulation beyond JavaScript’s safe-integer range.
src/cloudflare/engine.ts Generalizes error-name handling without changing its runtime behavior.
src/cloudflare/protocol.ts Generalizes caught-error encoding while preserving the RPC error envelope.
src/cloudflare/runtime.ts Updates authorization-context normalization typing while retaining JSON runtime validation.
tsconfig.cloudflare.json Adds source aliases for no-emit Cloudflare type-checking without affecting generated package artifacts.
package.json Advances the package release metadata to 0.14.7.
src/version.ts Aligns the exported runtime version with the package release.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Worker[Cloudflare Worker] --> Runtime[CloudflareRuntime]
  Runtime --> ActorDO[Actor Durable Object]
  ActorDO --> SQLite[(Private SQLite state)]
  ActorDO --> Mailbox[Durable mailbox]
  ActorDO --> Effects[Effects and outboxes]
  Runtime --> SessionDO[Session Durable Object]
  SessionDO --> Browser[Hibernating WebSocket]
  ActorDO --> SessionDO
Loading

Reviews (3): Last reviewed commit: "Fix runtime version" | Re-trigger Greptile

Comment thread src/cloudflare/engine.ts
Comment thread src/cloudflare/runtime.ts Outdated
Comment thread examples/cloudflare/worker.ts Outdated
@cardmagic

Copy link
Copy Markdown
Owner Author

Addressed the review feedback in commit 89fdc9d:

  • Successful effect handlers now complete the effect outbox before staging a separate durable effect-callback outbox, so callback backpressure cannot rerun the external effect. Added assertions covering both records.
  • Replaced public Cloudflare API unknown defaults and authorization annotations with JSON boundary types where applicable.
  • Flattened the example WebSocket origin/upgrade routing into guard clauses.

Validation: pnpm run check and pnpm run test:cloudflare (34 passing).

@cardmagic

Copy link
Copy Markdown
Owner Author

Updated the Cloudflare example in commit 77f270f:

  • replaced the counter with a ShoppingCart Durable Object
  • added add/remove/clear-later cart operations, totals, item counts, and realtime observables
  • updated routes, Wrangler name, and documentation
  • added direct README links to the actor, Worker, Wrangler config, and generated environment types

Validated with pnpm run check, pnpm run check:cloudflare, and a local Wrangler smoke test covering cart reads and item additions.

@cardmagic

Copy link
Copy Markdown
Owner Author

@greptile review the latest commit 77f270f again. Please re-check the previously addressed effect-callback durability issue, Cloudflare public API/type shape, and the updated shopping-cart example. Report any remaining blocking findings and include the final confidence score.

Comment thread examples/cloudflare/shopping-cart.ts
@cardmagic

Copy link
Copy Markdown
Owner Author

Addressed all current Greptile findings in commit 7d1c0da:

  • validate accumulated cart quantities after addition to preserve safe-integer precision
  • remove the remaining unknown annotations in the flagged Cloudflare runtime boundaries using generic/concrete types
  • retain the separate durable effect-callback outbox fix
  • add a regression test for cart quantity overflow

Validation: pnpm run check, pnpm run test:cloudflare (35 passing), and pnpm run check:cloudflare all pass. Please review the latest commit again and report the final confidence score.

@cardmagic

Copy link
Copy Markdown
Owner Author

@greptile review the latest commit 78f4d70 again. Re-check all previously addressed findings and report the final confidence score, with no unresolved threads.

@cardmagic
cardmagic merged commit 3cdf80e into main Sep 5, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant