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: Miniflare KV persistence not working in Wrangler2 --local mode

See original GitHub issue

What version of Wrangler are you using?

0.0.24

What operating system are you using?

Mac OS (ARM64)

Describe the Bug

It seems as Wrangler2 uses Miniflare under the hood in --local mode, many Miniflare features should work, especially persistence around KV etc. But for some reason persistence doesn’t kick in when using

[miniflare]
kv_persist = true

in wrangler.toml. Also other kv_persist options don’t work, KV namespace are just empty on each change of a worker file. This really hurts productivity, I’m assuming this is unintended and should work?

Using typescript and modules, can provide a minimal reproduction case once this is confirmed as a bug.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
threepointonecommented, Apr 7, 2022

We have a fix in place, you can try it with wrangler@alpha. We will revisit it and make it better, but it should hopefully unblock it for you now. We will do a beta release soon too. Thank you for reporting!

1reaction
threepointonecommented, Apr 6, 2022

We’d only just started working on this, hence the experimental flag. What the flag does, is enable persistence for kv/durable_objects/cache in miniflare https://github.com/cloudflare/wrangler2/blob/ed4f2ef00f86374ac7d1ac6ff072d939c80b6c18/packages/wrangler/src/dev/local.tsx#L163-L170 This does persist to disk. However, we use a fresh temp directory where the actual worker is bundled, and that temp directory disappears when you close wrangler dev. Instead, we should be persisting to a path relative to the working directory, so that it sticks around in a known location (and let users like you decide what to do with the generated files). I’ll send a fix for this soon.

The workaround for now if you want to test persistence, is to use regular “remote” mode. But we’ll fix it very soon!

Read more comments on GitHub >

github_iconTop Results From Across the Web

BUG: `--experimental-enable-local-persistence` stores KV ...
Mac Describe the Bug Wrangler 2 sets Miniflare's kvPersist, durableObjectsPersist and cachePersist options to the same string path value ...
Read more >
Doubling down on local development with Workers: Miniflare ...
These types of issues are really difficult for developers to debug, as they don't appear locally, and step-through debugging of deployed Workers ...
Read more >
Changelog - Miniflare
Fix delivery of incoming WebSocket error events; Ensure only scheduled Durable Object alarms are ... Previously, if Durable Object persistence was enabled, ...
Read more >
Miniflare - npm.io
Miniflare is a simulator for developing and testing Cloudflare Workers. 🎉 Fun: develop workers easily with detailed logging, file watching and pretty error...
Read more >
Workerd : le moteur d'exécution JavaScript / Wasm qui ...
https://blog.cloudflare.com/miniflare-and-workerd/ ... Some error other than 404? ... --persist Enable persistence for local mode, using default path: ...
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