Deploying with keep-vars not working anymore

Hi team ! I hope you're doing great ? I'm currently facing a issue that broke parts of our prod environments. When using the command wrangler deploy --keep-vars, wrangler is overriding the variables set up by the Script API. It was working well for the past 6 months without any issues, but for the last few days it completely overrides all the bindings that were previously defined. I'm attaching a screenshot of the same pipeline (the deployment action was not modified) before the error was introduced (Sun, 09 Jun 2024) and after (Sat, 15 Jun 2024). The CI job looks like the following:
name: Deploy Worker
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
environment: prod
steps:
- uses: actions/checkout@v4
- name: Build & Deploy Worker
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
command: deploy --keep-vars
name: Deploy Worker
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
name: Deploy
environment: prod
steps:
- uses: actions/checkout@v4
- name: Build & Deploy Worker
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
command: deploy --keep-vars
Is there anything that we could do to retain the bindings without breaking our prod ? Also why was it working for the last couple of months and now it breaks every times ? Cheers ! Roni
No description
No description
10 Replies
Walshy
Walshy2mo ago
just to be clar, what is being removed exactly?
wrangler is overriding the variables set up by the Script API.
it completely overrides all the bindings that were previously defined.
--keep-vars will keep env vars, json binding + secrets but not anything else
lupin
lupin2mo ago
It removes the Queues binding that were previously defined
Walshy
Walshy2mo ago
Yeah that's expected, bindings are not kept with --keep-vars -- it will only do env vars
lupin
lupin2mo ago
Why was it working correctly then before the 15th of June ?
Walshy
Walshy2mo ago
Possibly a bug that was fixed but I'm not aware of it ever keeping queues The way it works is that it sends what types to keep, so wrangler will send us ["plain_text", "json", "secret_text"] and we keep those types
lupin
lupin2mo ago
Is it possible that there was a change where Queues were being treated as env variables before and then the logic changed ? As for now do you know how we could fix this ? As described this breaks our prod everytime we try to deploy ^^'
Walshy
Walshy2mo ago
No, queue have a distinct type - they could never have been typed as an env var -- we have very strict logic around this I thought Wrangler had a way to specify types to keep however I can't see it in the docs, messaged the team about it Wrangler team said there is not a field today I'd recommend filing an issue on workers-sdk requesting one: https://github.com/cloudflare/workers-sdk/issues
lupin
lupin2mo ago
Thanks for the additional information. I imagine that it would take some time between the Feature Request and the full implementation. In the meantime do you have any idea how we could mitigate this issue ? Also if you ever happen to find out why it was working before, I'm genuinely interested :D
Walshy
Walshy2mo ago
Can you not specify the queue in your wrangler.toml?
lupin
lupin2mo ago
We are creating the queues dynamically through another worker and using the API to link the producer and consumer So when we redeploy the producer, all the queues binding are removed. I imagine that the best way to mitigate would be to create a script at build time to pull all the queue bindings from the API and reconstruct the toml and inject it at this moment. But it feels hacky to do so
Want results from more Discord servers?
Add your server