Deployment Error: workers.api.error.placement_and_...
# workers-help
i
Hi all! I'm suddenly getting the following error when trying to deploy an worker, as the error might indicate, we do have placements set to smart and we have a queue consumer / producer set in the same worker. I feel like this didn't happen before and wonder what changed, and if it's not possible to have smart placements enabled with queue consumers / producers?
s
Placements and triggers sounds like it doesn't like smart placement in combination with crons 🤔
i
I feel like this did work before, turning off smart placement with
[placement] mode = "off"
gives me
workers.api.error.unknown [code: 10013]
. Turning off smart placement in the dashboard also gives me
An unknown error occured. (Code: 10013)
We don't have any cron bindings in wrangler.toml, we did export a scheduled function (for once we enabled a cron job), but even after commenting this out the same issue happens
s
Could you share an account id & script name?
Internal errors don't sound good..
i
7f80802cc22f5b5cc65331d4e2523f79
- api-service-prod
s
@Vero 🐙 could you inquire about this
v
raising
i
Maybe relevant to know, probably not, saw the incident in IAD this morning, our worker might have been smart placed there since we have one of our data services running there I believe
v
Smart placement doesn’t work with cron triggers. They'll check the unknown error in 1h or so
i
@Vero 🐙 that's good to know, but we currently don't have any cron triggers, only queues / KV. We did have a
scheduled
function exported (for once we start using cron triggers), but even after commenting it out and re-deploying same issue occurs.

https://cdn.discordapp.com/attachments/1111627637912244254/1111641217109864478/image.png

@Vero 🐙 let me know if anything else is needed, would love to deploy again as soon as possible!
v
they say they aren't sure commenting out scheduled cron triggers works as expected. They've had problems with this in the past, and ended up having to create an empty array for the cron trigger in wrangler.toml to make it go away
not sure if that happens with scheduled functions
i
Same result with the scheduled function removed, and with
Copy code
[placement]
mode = "smart"

[triggers]
crons = []
In my wrangler.toml
m
Hey @ItsWendell ! I think our docs are a bit contradictory, and the example says
crons
when it should be
cron
. Try
cron = []
We're looking into the unknown error that you're seeing now. That obviously shouldn't happen.
Ugh, my bad. It is
crons
. Our docs need updating!
i
Alright, keep me posted!
m
@ItsWendell just confirming that it's not working, even when you keep smart placement on?
Is that giving you the "unknown" error, or the "placement_and_triggers_configured" error?
i
Correct,
Copy code
[placement]
mode = "off"

[triggers]
crons = []
is giving me
workers.api.error.unknown [code: 10013]
m
No, I mean, even when you keep smart placement on
ie,
mode = "smart"
i
Copy code
[placement]
mode = "smart"

[triggers]
crons = []
is giving me
workers.api.error.placement_and_triggers_configured [code: 100150]
m
I think we've recognized a bug with queues and turning smart placement off. But I can't quite figure out why it would error with smart placement kept on
Ahhh
Ok
So different error
i
Yeah
@mhart I can sent you full configuration of my toml file if needed
m
Unfortunately I think turning smart placement off with queues is going to be a bigger fix. But I think we can fix the cron trigger logic a bit quicker
i
@mhart as long as I can deploy again that would be great!
m
@ItsWendell yeah, totally realize that. Ok, one possibility is deleting the cron schedule via the API. https://developers.cloudflare.com/api/operations/worker-cron-trigger-update-cron-triggers
Copy code
curl --request PUT \
  --url https://api.cloudflare.com/client/v4/accounts/7f80802cc22f5b5cc65331d4e2523f79/workers/scripts/api-service-prod/schedules \
  --header 'Content-Type: application/json' \
  --header 'X-Auth-Email: ' \
  --data '[]'
Let me know if you need help with the authorization aspect
We'll be rolling out a better fix than this obviously, but short-term I'm hoping this should unlock you
So you can use either
X-Auth-Email: 123
,
X-Auth-Key: 123
, or
Authorization: Bearer 123
– depending on what sort of token you have
My Profile > API Tokens and select Create Token
i
@mhart no results:
Copy code
curl --request PUT \
  --url https://api.cloudflare.com/client/v4/accounts/7f80802cc22f5b5cc65331d4e2523f79/workers/scripts/api-service-prod/schedules \
  --header 'Content-Type: application/json' \
  --header 'Authorization: Bearer XXX' \
  --data '[]'

{
  "result": {
    "schedules": []
  },
  "success": true,
  "errors": [],
  "messages": []
}
Copy code
workers.api.error.placement_and_triggers_configured [code: 100150]
Also get request is return this:
Copy code
{
  "result": {
    "schedules": []
  },
  "success": true,
  "errors": [],
  "messages": []
}
@mhart Can you confirm whether this is still being looked into?
m
@ItsWendell it is, yes
Have you commented out the
scheduled
handler btw?
I think you said you removed it in one of your earlier messages – just wanted to make sure that was still true
i
Yes completely removed
m
Yeah ok. Really sorry about that. We're rolling out a hotfix that should allow you to get out of this state. Unfortunately you just happened to get caught between the period where we disallowed cron triggers and smart placement to coexist – but you already had a
scheduled
handler. And the reason you can't turn it off is because there are some complications with smart placement and queues specifically.
i
Appreciate the support! So it was just having a scheduled handler in my worker that caused it to register as a cron worker? I don't think we ever had it registered in wrangler.toml
@mhart any updates? Seems like we're still receiving the same error:
Copy code
workers.api.error.placement_and_triggers_configured [code: 100150]
m
Yeah, sorry, multiple hotfixes clobbering each other today. Will update you real soon
Ok, you should be able to deploy now, with smart placement on
We'll get another fix out to allow you to turn smart placement off
But I think (I hope) you're now unlocked to get around the cron triggers issue
(turning smart placement off is basically an issue with the queue consumer – but there should be no harm in leaving it on until that's fixed)
i
Seems like I can deploy now with smart placements on*! Thanks for fixing this! Would love to hear about the recommendations around crons / smart placements for when we actually implement crons, then we might do it in another worker!
m
Yeah, currently our thinking is that cron isn't really a good use case for smart placement – latency isn't (usually) as much of an issue with cron/scheduled jobs
i
Yeah makes sense, people might have a single worker handling different things though: queues, api routes, jobs
m
yeah tbh our recommendation is to split your worker up if you want use smart placement (and use service bindings if needed). But maybe we can just not run the cron (and maybe queues) parts as smart placed. We’ll see what makes sense!