workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

Improve error message when trying to use Durable Objects with service-worker format Workers

Open smg-tilman opened this issue 1 year ago • 1 comments

Which Cloudflare product(s) does this pertain to?

Workers Runtime, Other

What version(s) of the tool(s) are you using?

wrangler 3.27.0

What version of Node are you using?

v18.19.0

What operating system and version are you using?

Mac OS

Describe the Bug

Observed behavior

wrangler deploy does not work and errors with the code following error:

➜ wrangler deploy                      
 ⛅️ wrangler 3.27.0
-------------------
▲ [WARNING] The entrypoint src/r***r.ts has exports like an ES Module, but hasn't defined a default export like a module worker normally would. Building the worker using "service-worker" format...


Your worker has access to the following bindings:
- Durable Objects:
  - IP***DO: Ip***Do (defined in ./src/req***er.ts)
- KV Namespaces:
  - IP***3: 72d***3a07e
- Vars:
  - ENVIRONMENT: "staging"
Total Upload: 559.06 KiB / gzip: 104.16 KiB
 
✘ [ERROR] A request to the Cloudflare API (/accounts/***/workers/scripts/***) failed.

  Cannot apply new-class migration to class Ip***Do that is not exported by script [code: 10070]

Expected behavior

The migration should work as expected

Steps to reproduce

  • Create a worker in service-worker format
  • Create a migration in worker.toml
[durable_objects]
bindings = [
  { name = "IP_***_DO", class_name = "Ip***Do", script_name = "./src/ip***do.ts" }
]
[[migrations]]
tag = "v1"
new_classes = ["Ip***Do"]
  • the error should occur error

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

Cannot apply new-class migration to class Ip***Do that is not exported by script [code: 10070]

smg-tilman avatar Feb 07 '24 14:02 smg-tilman