#Cannot create binding for class DurableObject2 that is not exported by the script [code: 10061]

2 messages · Page 1 of 1 (latest)

real pendant
#

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:

% npx wrangler publish -c wrangler.staging.toml --outdir dist
Your worker has access to the following bindings:
- Durable Objects:
  - DO: DurableObject
  - DO2: DurableObject2
...
✘ [ERROR] A request to the Cloudflare API (/accounts/wwwwww/workers/scripts/kkkkkkk) failed.

  Cannot create binding for class DurableObject2 that is not exported by the script [code: 10061]
  
  If you think this is a bug, please open an issue at:
  https://github.com/cloudflare/workers-sdk/issues/new/choose

As you can see, the dist/index.js exports the class correctly:

% node
> a = await import('./dist/index.js')
[Module: null prototype] {
  DurableObject: [class DurableObject],
  DurableObject2: [class DurableObject2],
  default: { fetch: [AsyncFunction: fetch] },
  notFound: [Function: notFound]
}

In my src/index.ts there're those 2 lines:

export { DurableObject } from './durableObject'
export { DurableObject2 } from './durableObject2' // Added line

The wrangler.staging.toml file is like:

name = "kkkkkkkkk"
main = "src/index.ts"

[[durable_objects.bindings]]
name = "DO"
class_name = "DurableObject"

[[durable_objects.bindings]] # added
name = "DO2"
class_name = "DurableObject2"

[[migrations]]
tag = "v1" # Should be unique for each entry
new_classes = ["DurableObject", "DurableObject2"]

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:

export {
  DurableObject,
  DurableObject2,
  src_default as default,
  defaultHeaders,
}

It works if I remove all the references to DurableObject2, keeping just DurableObject. Where do I make the mistake?

wrangler: 3.15.0
system: MacOs

real pendant
#

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.