workers-sdk icon indicating copy to clipboard operation
workers-sdk copied to clipboard

🐛 BUG: Wrangler error deploying Platform Worker updates with DO migrations

Open kmaschi opened this issue 1 year ago • 0 comments

Which Cloudflare product(s) does this pertain to?

Workers for Platforms, Wrangler

What version(s) of the tool(s) are you using?

3.80.4 [Wrangler]

What version of Node are you using?

20.10.0

What operating system and version are you using?

Mac Sonoma 14.5

Describe the Bug

Observed behavior

Wrangler raises an error when deploying updates to Platform Workers that contain configuration for Durable Objects and Durable Object Migrations. This occurs when no changes are being made to the Durable Object Namespace that would warrant needing a new migration.

Error example:

...
✘ [ERROR] A request to the Cloudflare API (/accounts/REDACTED/workers/dispatch/namespaces/REDACTED/scripts/example-script-name) failed.

Migration tag precondition failed; current tag is 'v1' [code: 10079]
...

wrangler.toml example:

name = "example-script-name"
main = "src/index.ts"
compatibility_date = "2024-06-03"

[[durable_objects.bindings]]
name = "EXAMPLE_DURABLE_OBJECT"
class_name = "ExampleDurableObject"

[[migrations]]
tag = "v1" # Should be unique for each entry
new_classes = ["ExampleDurableObject"]

Expected behavior

Platform Worker with DO binding/migration should deploy updates without errors.

Steps to reproduce

  1. Create the a Platform Worker by deploying into an existing dispatch namespace:
    yarn wrangler deploy --dispatch-namespace REDACTED
    
  2. Observe the Platform Worker deploys successfully:
    % yarn wrangler deploy --dispatch-namespace REDACTED
    yarn run v1.22.19
    $ /wrangler-error-do-mig/node_modules/.bin/wrangler deploy --dispatch-namespace REDACTED
    
    ⛅️ wrangler 3.80.4
    -------------------
    
    Total Upload: 0.67 KiB / gzip: 0.37 KiB
    Your worker has access to the following bindings:
    - Durable Objects:
       - EXAMPLE_DURABLE_OBJECT: ExampleDurableObject
    Uploaded example-script-name (4.35 sec)
    Dispatch Namespace: REDACTED
    Current Version ID: REDACTED
    ✨  Done in 4.99s.
    
  3. Update the Platform worker by deploying again:
    yarn wrangler deploy --dispatch-namespace REDACTED
    
  4. Observe the Platform Worker fails to deploy:
    % yarn wrangler deploy --dispatch-namespace REDACTED
    yarn run v1.22.19
    $ /wrangler-error-do-mig/node_modules/.bin/wrangler deploy --dispatch-namespace REDACTED
    
    ⛅️ wrangler 3.80.4
    -------------------
    
    Total Upload: 0.67 KiB / gzip: 0.37 KiB
    Your worker has access to the following bindings:
    - Durable Objects:
       - EXAMPLE_DURABLE_OBJECT: ExampleDurableObject
    
    ✘ [ERROR] A request to the Cloudflare API (/accounts/REDACTED/workers/dispatch/namespaces/REDACTED/scripts/example-script-name) failed.
    
    Migration tag precondition failed; current tag is 'v1' [code: 10079]
    
    If you think this is a bug, please open an issue at:
    https://github.com/cloudflare/workers-sdk/issues/new/choose
    
    
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    

Similar in behavior to closed issue with regular Workers: https://github.com/cloudflare/workers-sdk/issues/705

Please provide a link to a minimal reproduction

https://github.com/kmaschi/cloudflare-wrangler-platform-worker-do-issue

Please provide any relevant error logs

No response

kmaschi avatar Oct 11 '24 18:10 kmaschi