fix(cloudflare): adopt durable object classes created outside alchemy#495
Open
sam-goodwin wants to merge 2 commits into
Open
fix(cloudflare): adopt durable object classes created outside alchemy#495sam-goodwin wants to merge 2 commits into
sam-goodwin wants to merge 2 commits into
Conversation
When adopting a worker not created by Alchemy (raw API/Wrangler/dashboard), its Durable Object classes have no alchemy:do logical-id->class tag, so every class fell into newSqliteClasses and Cloudflare rejected the migration for trying to create a class that already exists. Fall back to matching the observed cloud binding by binding name so the existing class is reused (or renamed) instead of recreated. Closes #486 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
|
Install the packages built from this commit: alchemy bun add alchemy@https://pkg.ing/alchemy/65e518a@alchemy.run/better-auth bun add @alchemy.run/better-auth@https://pkg.ing/@alchemy.run/better-auth/65e518a@alchemy.run/pr-package bun add @alchemy.run/pr-package@https://pkg.ing/@alchemy.run/pr-package/65e518a |
Add an "Adopting an Existing Durable Object" section to the DurableObjectNamespace JSDoc explaining the binding-name fallback, the one-time className-match constraint on the adopting deploy, and that renames only work on subsequent deploys once the alchemy:do tag exists. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Contributor
Website Preview DeployedURL: https://alchemyeffectwebsite-worker-pr-495-mdl4c5cm7zs4cq3t.testing-2b2.workers.dev Built from commit This comment updates automatically with each push. |
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.
Cloudflare.Workeralready adopts the worker itself, but its Durable Object class migrations only mapped logical-id→class throughalchemy:do:tags. A worker created outside Alchemy (raw API, Wrangler, dashboard) has no such tags, so on the adopting deploy every DO class fell intonewSqliteClasses— asking Cloudflare to create a class that already exists, which fails the migration.Fall back to matching the observed cloud binding by binding name (mirrors the original vendor behavior), so an existing class is reused — or renamed if the class name differs — instead of recreated.
Limitation (by design): on the adopting deploy the binding's class name must match the existing class. Once Alchemy writes the
alchemy:do:tag, later renames are driven by logical id.Test provisions a worker +
CounterSQLite DO class straight throughworkers.putScript(no Alchemy tags), then deploys an async inline-scriptWorker over the same name withadopt(true)and round-trips an increment through the reused class. Verified live, alongside the existing class-migration test.Closes #486