Wrangler migration from v1 to v3 and KV namespace issue

I have a small hobby site hosted on Cloudflare.
It is deployed from github as node.js using workers and Wrangler v1.1.0.

As v1 is a legacy version, I want to moved to v3.

I changed version to v3 and updated wrangler.toml from v1 syntax code:

name = "cms" type = "webpack" route = '' zone_id = 'myzone' account_id = 'myaccount' usage_model = '' compatibility_flags = [] workers_dev = true site = {bucket = "./public",entry-point = "workers-site"} compatibility_date = "2022-11-13"

to a recommended syntax from the migration guide:

name = "cms" account_id = 'myaccount' workers_dev = true site = {bucket = "./public",main = "workers-site/index.js"} compatibility_date = "2022-11-13"

Site is deployed without errors, but it is not loading correctly in the browser, there is a KV namespace error:
there is no KV namespace bound to the script

I tried a several versions, with ‘site’ parameter removed, with ‘main’ added, no luck

How can I fix it?

You need to add a KV binding to your wrangler.toml file.

kv_namespaces = [
  { binding = "<KV_NAMESPACE_BINDING>", id = "<KV_NAMESPACE_ID>" }

No change :frowning:

Here is the log:

:rocket: Running Wrangler Commands
/opt/hostedtoolcache/node/18.18.2/x64/bin/npx wrangler deploy
:partly_sunny: wrangler 3.13.2 (update available 3.15.0)
Your worker has access to the following bindings:

  • KV Namespaces:
    • name_I_used: id_I_used
      Total Upload: 53.88 KiB / gzip: 14.17 KiB
      Uploaded cms (1.01 sec)
      No deploy targets for cms (0.42 sec)
      Current Deployment ID: some_id
      :checkered_flag: Wrangler Action completed

in the browser I can see the same message: there is no KV namespace bound to the script

I added account ID and routes to the custom domain and now it shows that all is good (in theory)

Published cms (1.72 sec) https://myname.mydomain.workers.dev www.mydomain.com (custom domain)

still the same there is no KV namespace bound to the script error :thinking:

Do you see there are KV namespaces in the workers settings page?

Yes, I can see it, and it matches the setup. I can see files even.
All look good, even deployments are visible.

The only different is that on v1 it works, on v3 it doesn’t.

Is this in dev or production? Can you share an example of code and wrangler file, so I can try and recreate this issue?

The site setup is almost the same as described here: https://css-tricks.com/how-to-make-a-simple-cms-with-cloudflare-github-actions-and-metalsmith/

I found some time to troubleshoot.

Root cause: It was the change on the entry point syntax.

In the newer Wrangler it looks like you need to give an exact path. What worked before, was broken in the new version.
No error message during deployment, only error message on site

Just for a reference, in the case someone else faces a similar issue:
Here is a setup which worked fine for my little hobby project.

name = "myname"
compatibility_date = "2024-06-24" # wrangler update
workers_dev = true #if needed
usage_model = 'bundled'  #recommended to add, new feature
site = {bucket = "./public"} # removed entry point folder from here
main = "./src/workers-site/index.js" #added main item here

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.