question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

🐛 BUG: `wrangler dev -l` doesn't use preview KV namespace

See original GitHub issue

What version of Wrangler are you using?

2.0.22

What operating system are you using?

Mac

Describe the Bug

When running wrangler dev -l the KV store for a namespace will remain empty, despite data being present (added via wrangler kv:key put --binding=domains --preview true "key" "value"). Running wrangler kv:key list --binding=domains --preview true does return the key, however listing the keys from within the worker, or attempting to retrieve the key returns nothing.

wrangler lists the preview namespace id as an available binding when starting.

Turning off local mode restores expected functionality, and uses the preview namespace as expected, so it appears to be only a problem when running with the -l flag.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ni554ncommented, Aug 5, 2022

This is exactly what I thought after I updated my project from 0.0.19 to 2.0.24.

Wrangler was implicitly reading KVs from .mf/ folder that I was generating using Miniflare. But after the update, it was no longer the case. Cloudflare doc didn’t mention anything about the ephemeral nature of --local flag in pages dev command, which is set to true by default.

A single mention of --experimental-enable-local-persistence flag with wrangler-local-state folder could have saved much time.

0reactions
JacobMGEvanscommented, Aug 17, 2022

This is probably more a change for the cloudflare/cloudflare-docs repo—how does this language sound?

This runs an ephemeral local version of your worker, and will not be able to access data stored on Cloudflare’s edge (for instance, this includes your KV stores). If you’d like to persist data locally, the experimental option --experimental-enable-local-persistence will store data in the wrangler-local-state subdirectory.

Screenshot 2022-08-17 at 15 01 19

@penalosa Correct it is, I should be more clear which documentation next time. This is looking good, the technical writer team will follow up on the PR you make too.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cloudflare KV namespace doesn't bind - Stack Overflow
wrangler complains if there is no preview KV, so create them both. Next, create a kv_namespaces array entry and duplicate the preview_id in...
Read more >
How to do KV binding in wrangler.toml - Cloudflare Community
Add preview_id in the KV namespace, it's there so you can use a different namespace for prod and dev.
Read more >
AkI - River Thames Conditions - Environment Agency - GOV.UK
Modern drive in movie theater, Upr mayaguez ciencias sociales, L intranquille pontarlier. Vasco 2 x 2 cruzeiro 2000, Baksteenkoe?
Read more >
set node_options=--openssl-legacy-provider - You.com | The search ...
if using bash just run NODE_OPTIONS=--openssl-legacy-provider before any ... Describe the bug. wrangler dev and wrangler preview fail to run with error ......
Read more >
Building a Like Button with Cloudflare Workers
Give the namespace a name, in this case, likes and click, Add . You now have a KV store set up, you can...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found