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

Warn when wrangler dev is being used on a worker that binds to a durable object class implemented by a different script #319

Closed
Tracked by #563
a-robinson opened this issue Jan 27, 2022 · 2 comments · Fixed by #687 or #679
Assignees
Labels
enhancement New feature or request

Comments

@a-robinson
Copy link
Member

When a script containing a DO implementation is previewed using wrangler dev, the DO instances accessed in the preview session will have read access to the storage used by real objects in the real version of the namespace, but writes will be kept in memory and won't affect prod data.

However, if a script binds to a DO namespace implemented by a different script (or even if it's in the same script being previewed but the script_name is specified in the DO binding), then any requests sent by the preview session to DOs in that namespace will hit the real objects and any writes will modify the real prod data in that namespace. This is how KV works in preview too, but it's more confusing for DOs because of the fact that we do a copy-on-write overlay in the common case where the DO implementation is in the same script.

We should log a warning when wrangler dev is used on a script that has a DO binding that will be affected by this, giving the user a chance to acknowledge that they're sure they're ok with their preview session potentially overwriting real live data stored in the DOs.

@Electroid
Copy link
Contributor

Is there any technical reason we can't use the same dirty-write mechanic for DOs that are owned by another script? It makes sense for us in the meantime to surface a warning (maybe even a hard error?), but it would also be nice if we didn't need to do that in the first place.

@a-robinson
Copy link
Member Author

It's technically plausible, but would be quite a lot of work in both the runtime and the config service to support running the transitive closure of all depended-upon scripts in the preview session for a given script.

@Electroid Electroid added enhancement New feature or request and removed question labels Jan 27, 2022
@petebacondarwin petebacondarwin moved this to Must-have in workers-sdk Feb 21, 2022
@threepointone threepointone added this to the 2.0 milestone Mar 4, 2022
@petebacondarwin petebacondarwin self-assigned this Mar 19, 2022
petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this issue Mar 24, 2022
Durable Objects that are being bound by `script_name` will not be isolated from the
live data during development with `wrangler dev`.
This change simply warns the developer about this, so that they can back out before
accidentally changing live data.

Fixes cloudflare#319
@petebacondarwin petebacondarwin moved this from Must-have to In Review in workers-sdk Mar 24, 2022
petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this issue Mar 24, 2022
Durable Objects that are being bound by `script_name` will not be isolated from the
live data during development with `wrangler dev`.
This change simply warns the developer about this, so that they can back out before
accidentally changing live data.

Fixes cloudflare#319
petebacondarwin added a commit to petebacondarwin/wrangler2 that referenced this issue Mar 24, 2022
Durable Objects that are being bound by `script_name` will not be isolated from the
live data during development with `wrangler dev`.
This change simply warns the developer about this, so that they can back out before
accidentally changing live data.

Fixes cloudflare#319
Repository owner moved this from In Review to Done in workers-sdk Mar 25, 2022
petebacondarwin added a commit that referenced this issue Mar 25, 2022
Durable Objects that are being bound by `script_name` will not be isolated from the
live data during development with `wrangler dev`.
This change simply warns the developer about this, so that they can back out before
accidentally changing live data.

Fixes #319
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
4 participants