Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use cwd for --experiment-enable-local-persistence #767

Merged
merged 1 commit into from
Apr 7, 2022

Conversation

threepointone
Copy link
Contributor

This sets up --experiment-enable-local-persistence to explicitly use process.cwd() + wrangler-local-state as a path to store values. Without it, local mode uses the temp dir that we use to bundle the worker, which gets wiped out on ending wrangler dev. In the future, based on usage, we may want to make the path configurable as well.

Fixes #766

@changeset-bot
Copy link

changeset-bot bot commented Apr 7, 2022

🦋 Changeset detected

Latest commit: 63883b9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
wrangler Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@threepointone threepointone force-pushed the local-persistence-path branch from 8d86783 to fb6547e Compare April 7, 2022 14:21
@github-actions
Copy link
Contributor

github-actions bot commented Apr 7, 2022

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2109591903/npm-package-wrangler-767

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/767/npm-package-wrangler-767

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/2109591903/npm-package-wrangler-767 dev path/to/script.js

This sets up `--experiment-enable-local-persistence` to explicitly use `process.cwd() + wrangler-local-state` as a path to store values. Without it, local mode uses the temp dir that we use to bundle the worker, which gets wiped out on ending wrangler dev. In the future, based on usage, we may want to make the path configurable as well.

Fixes #766
@threepointone threepointone force-pushed the local-persistence-path branch from fb6547e to 63883b9 Compare April 7, 2022 14:29
@JacobMGEvans
Copy link
Contributor

JacobMGEvans commented Apr 7, 2022

There is a flaky test/s. I reran the (macos) and it passed.

Edit: Found the old run for the workflow
https://github.com/cloudflare/wrangler2/runs/5870312974?check_suite_focus=true
Screen Shot 2022-04-07 at 11 12 28 AM

Copy link
Contributor

@JacobMGEvans JacobMGEvans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

// as an explicit path, or else it'll use the temp dir
// which disappears when dev ends
const localPersistencePathOrDisableLocalPersistence = enableLocalPersistence
? // Maybe we could make the path configurable as well?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configurable via the TOML or a flag?

Copy link

@hkochniss hkochniss Apr 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the way miniflare handles things, sure could be under another key to not expose the "miniflare" name, but the way it's handled there (default or specific path per KV, DO and cache) is pretty neat.

A CLI flag is also important IMO due to integration test ci/cd scenarios, where loading a test data set is important, and dynamic cache folder paths quickly become cumbersome with wrangler.toml

@threepointone threepointone merged commit 836ad59 into main Apr 7, 2022
@threepointone threepointone deleted the local-persistence-path branch April 7, 2022 18:20
@github-actions github-actions bot mentioned this pull request Apr 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐛 BUG: Miniflare KV persistence not working in Wrangler2 --local mode
3 participants