Skip to content

fix: correct cron expression and update Node.js to v20#90

Merged
waldekmastykarz merged 1 commit intopnp:mainfrom
qfai:fix/cron-expression-and-nodejs-version
Jan 15, 2026
Merged

fix: correct cron expression and update Node.js to v20#90
waldekmastykarz merged 1 commit intopnp:mainfrom
qfai:fix/cron-expression-and-nodejs-version

Conversation

@qfai
Copy link
Contributor

@qfai qfai commented Jan 15, 2026

Summary

This PR fixes two issues in the nodejs-typescript-policies sample:

1. Fix cron expression bug in connections.ts

Before:

const cronExpression = `0 0 0 ${currentDate.getUTCMonth()} ${currentDate.getUTCDay()} *`;
// Result: '0 0 0 0 4 *' - Invalid! Day cannot be 0

After:

const cronExpression = `0 0 0 ${currentDate.getUTCDate()} ${currentDate.getUTCMonth() + 1} *`;
// Result: '0 0 0 15 1 *' - Valid cron expression

The issue was:

  • getUTCMonth() returns 0-11, was incorrectly placed in the day position
  • getUTCDay() returns day of week (0-6), was incorrectly placed in the month position
  • Correct format: {second} {minute} {hour} {day} {month} {day-of-week}

2. Update Node.js version in azure.bicep

Updated WEBSITE_NODE_DEFAULT_VERSION from ~18 to ~20 since Node.js 18 is no longer supported.

Testing

  • Tested locally with F5 debug, Azure Function starts successfully without cron expression errors."

- Fix cron expression bug: use getUTCDate() for day and getUTCMonth()+1 for month
- Update Node.js version from 18 to 20 in azure.bicep as 18 is no longer supported
@waldekmastykarz waldekmastykarz merged commit 014f9ba into pnp:main Jan 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants