Reputation: 732
I'm running a schedule job on button click from my frontend App sent to Nextjs (NodeJS) backend /api/ function which doesn't get triggered upon sending another request... Does anyone have an idea how could I persist NodeJS server to execute function at the given time without going to sleep and the need to send another request to it?
const job = schedule.scheduleJob(
buildingName,
endBuildTime,
function () {
console.log("Execute update!");
}
)
Upvotes: 1
Views: 1428
Reputation: 857
Serverless functions (Next.js API routes) have an execution timeout, which is 10 seconds
on the hobby plan.
After 10 seconds
, your function will be killed if it is still processing. Which is what is happening to your function. You are scheduling a job but that job will never execute because the function has been killed.
Upvotes: 4