Durable object not exported error and Unknown arguments: new-class

I’m trying to publish a worker along with a new durable object class. When I do so, I get
“Cannot create binding for class SessionsDB that is not exported by the script” … even though the class is exported by the script. (SessionsDB is the class name)

I read in this thread that I need to pass the --new-class argument. However, when I run wrangler publish --new-class SessionsDB I get ✘ [ERROR] Unknown arguments: new-class, newClass

I’m using wrangler version 2.9.1.

I have the following in my wrangler.toml

[durable_objects]
bindings = [{name = "SESSIONS_DB", class_name = "SessionsDB"}]

[[migrations]]
tag = "v1"
new_classes = ["SessionsDB"]
1 Like

The --new-class argument should not be necessary when using migrations in your wrangler.toml.

Are you able to successfully publish the example template linked from Using Durable Objects · Cloudflare Workers docs

Same problem. Did you ever get a fix to this?

Unfortunately not. I did try publishing the “Build a counter” example and that worked fine, but for some reason my own case always returns a “Cannot create binding for class SessionsDB that is not exported by the script” error, despite the fact that I have triple checked, and it really seems like I am indeed exporting the SessionsDB class from the main entry point. There must be some difference between my project and the example, but I still haven’t figured out what it is.