Repository navigation
Explicit Durable Object deletion, renamedFrom and conditional bindings - #7
Open
jonasnobile wants to merge 1 commit into
Open
jonasnobile wants to merge 1 commit into
jonasnobile wants to merge 1 commit into
Conversation
…indings Removing a Durable Object binding no longer deletes the class and its data implicitly. A class that was bound in the previous generated config and is no longer bound now fails the run, before any resource is applied or any config is written, until the definition says what to do: - deletedDurableObjects: ['Old'] on the worker deletes the class - renamedFrom on DurableObject generates a renamed_classes migration - deleteDurableObjectsOnRemoval: true keeps the old implicit deletion, false keeps the class without a binding Live classes are computed by replaying the migration history, so a deleted class can be created again. The history is stripped on deletion only when the class was created once and never renamed, transferred or deleted. Bindings set to false, null or undefined are skipped. README: list all resources and which of them oblaka provisions, document conditional bindings, the Durable Object lifecycle and wrangler types. BREAKING CHANGE: deleteDurableObjectsOnRemoval now defaults to failing the run instead of deleting the removed class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Wy7TXnDtEsRyAsc254tCs3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ideas taken from Cloudflare's new
cloudflare.config.ts(itsexportsmap withdeleted/renamedstates), adapted to the wrangler migrations oblaka already generates.Durable Objects are never deleted by accident
Removing a binding used to append a
deleted_classesmigration by default, so deleting one line deleted the stored data, and a class rename looked like delete + create.Now a class that was bound in the previous generated config and is no longer bound fails the run. The check runs for the whole worker tree before any resource is applied or any config is written. The definition has to say what should happen:
renamedFromgeneratesrenamed_classes, so the data moves to the new class.deletedDurableObjectsdeletes the listed classes.deleteDurableObjectsOnRemoval: truekeeps the old implicit deletion,falsekeeps removed classes without a binding.renamedFromnames a class that is still bound, when two classes rename from the same one, or when a class is both bound and listed for deletion.Live classes are computed by replaying the migration history (
src/utils/migrations.ts), shared byDurableObjectandContainer. A deleted class can be created again, andrenamedFrom/deletedDurableObjectscan stay in the definition after deploy. The existing history stripping on deletion is kept only for a class created once and never renamed, transferred or deleted. Longer histories stay intact so they remain consistent.Breaking: an unset
deleteDurableObjectsOnRemovalnow fails the run instead of deleting the removed class.Conditional bindings
A binding set to
false,nullorundefinedis skipped (env === 'production' && new KVNamespace(...)). The README warns against makingDurableObject/Containerbindings conditional, because all environments share one migration history in the generated file.README
Envtypes viawrangler typeson the generated config. Checked: that already types DO namespaces by class. A TS-levelInferEnvwould make worker typechecks pull in oblaka's Node sources, so it was dropped.Not verified
Whether Cloudflare accepts
deleted_classesfor a class whose creation was stripped from the history, when deploying to a fresh environment. That behaviour predates this PR.Checks
bun test(136 pass),typecheck,lint,format:check.🤖 Generated with Claude Code
https://claude.ai/code/session_01Wy7TXnDtEsRyAsc254tCs3