Cannot create binding for class DurableObject2 that is not exported by the script [code: 10061]
I'm editing an old version of my CloudFlare worker to add a new Durable Object called DurableObject2
When I try to deploy it, this is the error:
As you can see, the
dist/index.js
exports the class correctly:
In my src/index.ts there're those 2 lines:
The wrangler.staging.toml file is like:
I also debug which content is uploaded to PUT https://api.cloudflare.com/client/v4/accounts/wwwwwww/workers/scripts/kkkkkk?include_subdomain_availability=true&excludeScript=true
, and it exports correctly the classes at the end of the content:
It works if I remove all the references to DurableObject2, keeping just DurableObject. Where do I make the mistake?
wrangler: 3.15.0
system: MacOs2 Replies
The issue probably was in
migrations
part. I said "probably" because at the end I deleted the worker and reinstalled it. Anyway I added also a 3dh DurableObject and the error returns back. Changing the mitrations
part, the deploy goes well.
Bad error message.indeed, for every new class you need a migration where it's added (
new_classes
) - and old migrations need to stay as they were, so you'd have to copy your current migration, change the tag (to something unique) and put your new class into the list