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

Disable persistence by default (unless --enable-persistence passed) #321

Merged

Conversation

geelen
Copy link
Contributor

@geelen geelen commented Jan 27, 2022

Thought it was time to pull my finger out and send a PR, now that I don't have the "but I don't know Rust" defence to lean back on...

@changeset-bot
Copy link

changeset-bot bot commented Jan 27, 2022

🦋 Changeset detected

Latest commit: f4a3c9c

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

@geelen geelen force-pushed the glen/disable-persistence-by-default branch from b32b364 to 4bcb4a3 Compare January 27, 2022 19:02
@geelen
Copy link
Contributor Author

geelen commented Jan 27, 2022

This resolves #320

@threepointone
Copy link
Contributor

call it --experimental-enable-local-persistence? So we can unblock you, the flag is clearer, and we can iterate on this if needed. I'm coming around to the idea that we should disable persistence for dev.

Comment on lines +1 to +5
{
"printWidth": 80,
"singleQuote": false,
"semi": true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps this change is something to discuss in a separate PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I see, this is to match the current settings, and override any user-level config that a developer might have...?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah my ~/.prettierrc is set to the opposite of all of these, so running prettier on anything exploded the diffs. I ran npm run prettify after adding this and it changed nothing, except the npm run check:format on CI still failed. Not sure why...

// break;
// }
// }
// );
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this supposed to be commented out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Damn sorry that was me trying to fix something else... Will redo and repush

@@ -40,6 +40,7 @@ export type DevProps = {
initialMode: "local" | "remote";
jsxFactory: undefined | string;
jsxFragment: undefined | string;
enablePersistence: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

BIKESHED: enableLocalPersistence or localModePersistence or something that signifies that this only affects local mode?

Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

We'll be needing a change-set too!
Run the following in the root of the project.

npx changeset

Choosing to bump the wrangler package by only a patch version (since we are in 0.x version mode)

@geelen geelen force-pushed the glen/disable-persistence-by-default branch from fbc9a0a to a499762 Compare January 27, 2022 21:02
Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

LGTM - the failure is a TypeScript one...

Error: [check:type  ] packages/wrangler/src/__tests__/dev.test.tsx(49,6): error TS2741: Property 'enableLocalPersistence' is missing in type '{ name: string | undefined; entry: string; port: number | undefined; buildCommand: { command?: string | undefined; cwd?: string | undefined; watch_dir?: string | undefined; }; format: CfScriptFormat; ... 9 more ...; bindings: { ...; }; }' but required in type 'DevProps'.

Looks like you need to update dev.test.ts

@geelen geelen force-pushed the glen/disable-persistence-by-default branch from f38b835 to 5a47d35 Compare January 27, 2022 21:15
@geelen geelen mentioned this pull request Jan 27, 2022
"wrangler": patch
---

Disabled local persistence by default & added --experimental-enable-local-persistence flag
Copy link
Contributor

Choose a reason for hiding this comment

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

Oh last thing... Could you add a breaking changes notification here... Something like:

BREAKING CHANGE:

When running `dev` locally any data stored in KV, Durable Objects or the cache are no longer persisted between sessions by default.

To turn this back on add the `--experimental-enable-local-persistence` at the command line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Like this?

@geelen geelen force-pushed the glen/disable-persistence-by-default branch from 5a47d35 to 25d1d1f Compare January 28, 2022 09:31
feat: Added —experimental-enable-local-persistence flag to turn back on
chore: added project-level .prettierrc, otherwise system-wide settings cause massive diffs
chore: added changeset
@geelen geelen force-pushed the glen/disable-persistence-by-default branch from 25d1d1f to f4a3c9c Compare January 28, 2022 11:28
Copy link
Contributor

@petebacondarwin petebacondarwin left a comment

Choose a reason for hiding this comment

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

:shipit:

@petebacondarwin petebacondarwin merged commit 5b64a59 into cloudflare:main Jan 28, 2022
@github-actions github-actions bot mentioned this pull request Jan 28, 2022
@petebacondarwin
Copy link
Contributor

@geelen - oops:

[check:lint  ] /Users/pbacondarwin/dev/wrangler2/packages/wrangler/src/dev.tsx
[check:lint  ]   320:6  warning  React Hook useEffect has a missing dependency: 'props.enableLocalPersistence'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

threepointone added a commit that referenced this pull request Jan 28, 2022
This fix passes the correct worker name to `syncAssets` during `wrangler dev`. This function uses the name to create the backing kv store for a Workers Sites definition, so it's important we get the name right.

I also fixed the lint warning introduced in #321, to pass `props.enableLocalPersistence` as a dependency in the `useEffect` call that starts the "local" mode dev server.
@threepointone
Copy link
Contributor

fix for the lint warning included in #333

threepointone added a commit that referenced this pull request Jan 29, 2022
This fix passes the correct worker name to `syncAssets` during `wrangler dev`. This function uses the name to create the backing kv store for a Workers Sites definition, so it's important we get the name right.

I also fixed the lint warning introduced in #321, to pass `props.enableLocalPersistence` as a dependency in the `useEffect` call that starts the "local" mode dev server.
@github-actions github-actions bot mentioned this pull request Jan 29, 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.

3 participants