Scheduled function shows as deployed but never runs and there are no logs

Hey @hrishikesh,

Thank you for your reply & help. I’ll send you a copy of the repo to your personal inbox, to limit exposure of it. Hope its enough!

Hi @voormedia

I can see the function being processed but not handled as a scheduled function. Can you please do the following:

  • change the content of the function so we build it again (one of the triggers is having different content)
  • publish that deploy and let us know so we can take a closer look at this

That will allow us to check a more recent version of the function.

I’m having a similar issue as above. Notably, my function is written in TypeScript, but follows basically the same code as the scheduled functions guide. Is it required that I use the CommonJS require(...) / module.exports.handler syntax, as listed in the docs? I’d really hope not, so that I can use TS like the rest of my project, and as I have with non-scheduled functions in the past.

Here’s a version without the API calls:

import { Handler, schedule } from "@netlify/functions";

// Mon-Fri, a bit before :30 and :00 from 12am through 1am and 11am through 11pm UTC
// (4:26+4:56am - 6:26+6:56pm PT)
const SCHEDULE = `26,56  0-2,12-23 * * 1-5`;

const handler: Handler = schedule(SCHEDULE, async () => {
  if (process.env.NETLIFY_BUILD_HOOK_URL) {
    // fetches data, calls build hook if applicable, console.logs, returns 200,
  } else {
    // needs configuration, console.log
  }
});

export { handler };

It’s been deployed and published, but similarly shows up without the “Scheduled” marker, and still lists an endpoint, even though the docs make it seem like it wouldn’t.

Scheduled functions enabled:

Hi, @gualter . Thank you for your help!

I’ve slightly changed the function and redeployed it. We cross our fingers that you’ll be able to figure out what’s wrong.

Hey there folks, thanks so much for your patience here. Our support team is still looking into this and will follow up in this thread when we have more information.

Hey @voormedia and @niceshadowraze,

We’ve good news for both of you. Turns out that even though your codes are syntactically correct, it doesn’t satisfy our schedule matching logic which is why it was failing.

@voormedia, I believe you’ve already tried this, but the repo you shared didn’t have this solution, so I made the changes in the copy you provided and it appears to work fine.

The solution for both of you is to declare the schedule in your netlify.toml like this:

[functions."function-name"]
  schedule = "@hourly"

Hey @hrishikesh ,

I reverted to having the scheduling done in the .toml file and it works now!

Thank you very much for your support, guys. Really appreciated <3

1 Like

Hi everyone… I was having this issue. Everything was configured correctly and it was on my “main” production branch. The “scheduled” badge showing up next to my functions but still nothing was working.

I decided to setup a new Netlify site & Github repo with only my functions and it worked!

The original project was an existing Next.js project. Scheduled functions just didn’t work in this environment.

1 Like

This worked for me as well! Syntactically correct, but only when I moved the cron info into the toml file did it show up as scheduled!

Thanks for sharing this detail with the community @chrispalka