Cannot create binding for class in script ./rate-l...
# workers-help
s
I'm trying to publish adding durable object to my worker. I have a new file in the project folder called rate-limiter.js. I'm getting this error, when running wrangler publish. * Cannot create binding for class in script rate-limiter that does not exist [code: 10061]*
Copy code
// rate-limiter.js
export class APIRequestCounter {}

}
Copy code
// index.js
import { APIRequestCounter } from './rate-limiter.js';
export default {
  async fetch(request, env, ctx) {
  }
}
TRY 1: WRANGLER.toml
Copy code
[durable_objects]
bindings = [{name = "API_RATE_LIMITER", class_name = "APIRequestCounter", script_name = "rate-limiter.js"}]
TRY 2: WRANGLER
Copy code
[durable_objects]
bindings = [{name = "API_RATE_LIMITER", class_name = "APIRequestCounter", script_name = "rate-limiter"}]
TRY 3: WRANGLER
Copy code
[durable_objects]
bindings = [{name = "API_RATE_LIMITER", class_name = "APIRequestCounter", script_name = "./rate-limiter.js"}]
w
remove
script_name
that's Worker script
it let's you link one from another Worker
(yeah not a great name...)
s
I got this error. Could it because the wrangler.toml only has the index.js in the config? main = "index.js" Cannot create binding for class APIRequestCounter that is not exported by the script [code: 10061]
w
in your index.js, do
export { APIRequestCounter } from './rate-limiter.js'
s
Seems like I am getting closer. Cannot create binding for class APIRequestCounter because it is not currently configured to implement durable objects. Did you forget to apply a --new-class migration to it? [code: 10061]
[[migrations]] tag = "v1" # Should be unique for each entry new_classes = ["APIRequestCounter"] # Array of Durable Object classes
got it.
Thanks Walshy!