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:
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 !
Roni10 Replies
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
It removes the Queues binding that were previously defined
Yeah that's expected, bindings are not kept with --keep-vars -- it will only do env vars
Why was it working correctly then before the 15th of June ?
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
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 ^^'
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
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
Can you not specify the queue in your wrangler.toml?
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