Cloudflare #Workers possible #CRON #bug ? worker being called tens of times

Hi,

Context
worker script:
  • a) not using CLI; but web interface to copy/paste updated script, debug using console
script description
  • a) export both fetch and scheduled functions. since the worker could be executed manually by browsing its URL and periodically by cron settings
  • b) both functions do exactly the same
  • c) the worker flow is this: fetches gmail and gsheets api calls, generates an email-body summarizing some info, and sends JUST ONE EMAIL including that email-body usign sendgrid api
  • d) in order to understand when the worker's script was run, an epoch time variable is set at the very beginning and is added to the subject
  • e) the subject have 2 possible contents
  • f) the script works perfectly
script expected behaviour
  • when cron executes the worker, ONLY ONE EMAIL should be received (sendgrid's api is fetch once)
possible bug description, our unexpected CF worker's runtime execution

the reason I highlighted JUST ONE EMAIL is because, for some reason, many times i am receiving several identical emails as shown in the attached screenshot

a second surprising, amazingly unexpected result, is that for the same exact epoch time, i am receiving 2 subjects !! which is absolutely impossible considering that the worker is run once at that specific time, and the subject is set based on IF ELSE

if (emailsData.length > 0) {
subject = ${epochTime} - Real - ꔪ IMPORTANT emails found;
} else {
subject = ${epochTime} - Real - Nothing special;
}

one last comment

A similar script is also deployed to another worker. that worker had set a cron.
but now the corn is gone (i deleted it) - BUT THE WORKER is still being periodically executed.
or something like that... (i know that because i am receiving emails from that worker i did not executed manually)

Well, I really need some light on this. I am probably missing something.

In any case I need your clarification.

Thanks in advance
Screenshot_2024-11-07_at_11.10.50_AM.jpeg
Was this page helpful?