GAE
GAE
CDCloudflare Developers
Created by GAE on 11/11/2024 in #workers-help
Cloudflare #Workers possible #CRON #bug ? worker being called tens of times
i started to log the origin-IP and the userAgent. amazingly one userAgent value was: "Expanse, a Palo Alto Networks company, searches across the global IPv4 space multiple times per day to identify customers' presences on the Internet. If you would like to be excluded from our scans, please send IP addresses/domains to: [email protected]" from the IP 205.210.31.169
8 replies
CDCloudflare Developers
Created by GAE on 11/11/2024 in #workers-help
Cloudflare #Workers possible #CRON #bug ? worker being called tens of times
something that your approach is missing is that i am keeping track of how the worker was executed export default { async fetch(request, env) { const log = await start("manual", env); return new Response(log, { headers: { 'Content-Type': 'text/plain' } }); }, async scheduled(event, env) { const log = await start("cron", env); console.log(log); } }; so if the requests were called by bots, i should receive "manual" log, but i am not; instead i am getting "cron" meaning the worker is being called by the internal system of CF workers infrastructure
8 replies
CDCloudflare Developers
Created by GAE on 11/11/2024 in #workers-help
Cloudflare #Workers possible #CRON #bug ? worker being called tens of times
where can i check the existance of those certificates ? it would be great if i can search the record for my worker specific URL
8 replies
CDCloudflare Developers
Created by GAE on 11/11/2024 in #workers-help
Cloudflare #Workers possible #CRON #bug ? worker being called tens of times
thats right; but in this case the worker URL is a subdomain provided by CF. something like: myRareWorker.MyCFUsername.workers.dev so in order the worker to be knocked, the bots outthere should know this URL, and i cant find out how they could...
8 replies
CDCloudflare Developers
Created by GAE on 11/11/2024 in #workers-help
Cloudflare #Workers possible #CRON #bug ? worker being called tens of times
which bots ? the worker's URL is not published anywhere. i havent share it with nobody. and i think that is that would be the case, i should be receiving several emails, but with different subject (epochtimes)
8 replies
CDCloudflare Developers
Created by GAE on 11/11/2024 in #workers-help
Cloudflare #Workers possible #CRON #bug ? worker being called tens of times
//------- export default { async fetch(request, env) { const log = await start("manual", env); return new Response(log, { headers: { 'Content-Type': 'text/plain' } }); }, async scheduled(event, env) { const log = await start("cron", env); console.log(log); } }; //--------- async function start(log, env) { const epochTime = Math.floor(Date.now() / 1000); let emailsData = getEmails(); if (emailsData.length > 0) { subject = ${epochTime} - ꔪ; } else { subject = ${epochTime} - 0; } await sendLogByEmail(log, env, subject); return log; } //----------- async function sendLogByEmail(log, env, subject) { const apiKey = env.VAR_SG_APIKEY; const fromEmail = env.VAR_FROM; const toEmail = env.VAR_TO; const url = 'https://api.sendgrid.com/v3/mail/send'; const emailData = { personalizations: [{ to: [{ email: toEmail }], }], from: { email: fromEmail }, subject: subject, content: [{ type: 'text/plain', value: log, }], }; try { const response = await fetch(url, { method: 'POST', headers: { 'Authorization': Bearer ${apiKey}, 'Content-Type': 'application/json', }, body: JSON.stringify(emailData), }); if (!response.ok) { throw new Error(${response.status}); } } catch (error) { console.error(${error.message}); } }
8 replies
CDCloudflare Developers
Created by GAE on 11/11/2024 in #workers-help
Cloudflare #Workers possible #CRON #bug ? worker being called tens of times
Hi, thanks for taking time to help. Here is the basecode. it exports both fetch & scheduled both calls start() in order to run the script in both cases: if the worker is called by browsing it or by a cron an epochTime is registered to identify the worker specific, unique execution the start method look for an arrays of emails (code deleted for simplification) depending on the the lenght of the array, a sendgrid api call is done so send an email only one email is sent by worker execution, assigning the epochTime variable as the subject for reasons i cand figure out, sometimes i get several emails with the same, identical subject indicating that the worker was run those many times (sendgrid inst sending several identical emails) worker's code attached
8 replies