Initializing

My worker is stuck on Initializing workers.dev subdomain... is that due to the outages
26 Replies
Chaika
Chaika14mo ago
New account or worker? It is very likely related, I was getting that earlier though on existing workers when the incidient/api was worse. Does it prevent you from editing your worker or accessing it?
EdgiestNickel89
EdgiestNickel89OP14mo ago
The worker was just made today. I can edit and access it and it says it deployed successfully but it says Initializing workers.dev subdomain...
Chaika
Chaika14mo ago
If it's not causing issues, I would just advert your eyes from it for now, should go away when the incident is over By "access it", you mean actually trigger the worker right? If it doesn't show you the url, it'd just be <worker-name>.yoursubdomain (shown in overview).workers.dev
EdgiestNickel89
EdgiestNickel89OP14mo ago
I mean I can access its settings. The worker domain is inaccessable
Chaika
Chaika14mo ago
ah ok, yea this is def related to the outage, interesting though. Is this the first worker on your account or something? I can seem to create new ones fine on my end
EdgiestNickel89
EdgiestNickel89OP14mo ago
My first worker yes
Chaika
Chaika14mo ago
It's gotta do some setup then for your worker.dev domain I imagine. You could try adding a worker custom domain on one of your domains (if you have any in Cloudflare & if you can access it that menu under Triggers of the Worker), otherwise you'll probably just need to wait it out
EdgiestNickel89
EdgiestNickel89OP14mo ago
Its fairly basic I want a URL that I can give a ?code=somestring query and it will make a POST request to a different url with the body as {"content":somestring}
Chaika
Chaika14mo ago
yea, it's not about the worker code itself or anything, just about the ongoing service issues: https://www.cloudflarestatus.com/incidents/hm7491k53ppg
EdgiestNickel89
EdgiestNickel89OP14mo ago
Any alternatives that can achieve that?
Chaika
Chaika14mo ago
Converting a query string to a POST Request on a different url? Only Workers would be dynamic enough to do anything like that If you want to add this over an existing web server/origin, you could try adding the http route for it, it sounds like to me it's just the workers.dev domain having issues and not the worker itself
EdgiestNickel89
EdgiestNickel89OP14mo ago
Basically a GET request to the worker or whatever service url.com?code=MyString A POST request to another URL with body={"content":MyString}
Chaika
Chaika14mo ago
The only Cloudflare product that can really do dynamic stuff like that would be Workers You have the right answer to your question, just need to wait for service to be restored, or try adding a custom domain/route to the Worker to try to get around the worker.dev issues
EdgiestNickel89
EdgiestNickel89OP14mo ago
Its deploying and its no longer stuck on Initializing workers.dev subdomain... but whenever I try to access the worker but its doing this instead
No description
EdgiestNickel89
EdgiestNickel89OP14mo ago
Sorry I forgot to turn off ping And for some reason it says my worker has 71 requests The error message is: Cannot read properties of undefined (reading 'webhook') I have a secret called webhook Im getting it with event.env.webhook
Chaika
Chaika14mo ago
New Workers get issued a certificate (*.workername.subdomain.workers.dev), which go into the Certificate Transparency (CT) Logs, so you get a bit of bot traffic what's your code look like? If you're using module workers, you'd just grab env off the request. If old service workers with addEventListener, then they're just globals. event sounds like either a framework or something else
EdgiestNickel89
EdgiestNickel89OP14mo ago
I ended up just not using an environment variable. yeah I was using addEventListener to get the event and using event.env
addEventListener('fetch', event => {
event.respondWith(eventHandler(event));
});
async function eventHandler(event) {
const env = event.env;
addEventListener('fetch', event => {
event.respondWith(eventHandler(event));
});
async function eventHandler(event) {
const env = event.env;
Chaika
Chaika14mo ago
there's no env on event with addEventListener/service workers environment variables are just globals
EdgiestNickel89
EdgiestNickel89OP14mo ago
So how do I get it?
Chaika
Chaika14mo ago
If you named it webhook, would just be webhook or globalThis.webhook
EdgiestNickel89
EdgiestNickel89OP14mo ago
thanks
Chaika
Chaika14mo ago
no problem, if you can, I would consider migrating and using Module Format instead of Service Worker format/addEventListener: https://developers.cloudflare.com/workers/learning/migrate-to-module-workers/ Service Worker Format does not/will not support all future features and bindings, and it's slower and more messy For example, with module workers, that'd be like this:
export default {
async fetch(request, env, ctx) {
return new Response(env.webhook);
},
};
export default {
async fetch(request, env, ctx) {
return new Response(env.webhook);
},
};
Migrate from Service Workers to ES Modules · Cloudflare Workers docs
Write your Worker code in ES modules syntax for an optimized experience.
Chaika
Chaika14mo ago
no rush though, the guarantee with Workers is that old code will always keep running thanks to compatibility dates and such, not going to have service worker format workers stop working one day
EdgiestNickel89
EdgiestNickel89OP14mo ago
I was doing that first but when i was calling fetch() to make a POST request to the webhook it was trying to call itself
Chaika
Chaika14mo ago
The online editor is a bit silly and tries to autosuggest this.fetch() on autocomplete, make sure you're not doing that just bare fetch() is what you need
EdgiestNickel89
EdgiestNickel89OP14mo ago
I did and it said it requires 3 arguments but only 2 were given. The 3 refering to request, env and ctx
Want results from more Discord servers?
Add your server