fix: Update version to 2.56.15 and improve immediate task execution in scheduling logic

This commit is contained in:
2025-11-13 22:16:05 +01:00
parent 47424be67b
commit 67388539b2
3 changed files with 22 additions and 8 deletions

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "microsoft-rewards-bot",
"version": "2.56.14",
"version": "2.56.15",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "microsoft-rewards-bot",
"version": "2.56.14",
"version": "2.56.15",
"hasInstallScript": true,
"license": "CC-BY-NC-SA-4.0",
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "microsoft-rewards-bot",
"version": "2.56.14",
"version": "2.56.15",
"description": "Automate Microsoft Rewards points collection",
"private": true,
"main": "index.js",

View File

@@ -1051,7 +1051,20 @@ async function main(): Promise<void> {
// Check if scheduling is enabled
if (config.scheduling?.enabled) {
// Initialize scheduler
// IMPROVED: Run tasks immediately first, THEN start scheduler for future runs
// This ensures "npm start" always executes tasks right away instead of waiting until next scheduled time
log('main', 'MAIN', 'Scheduling enabled - executing immediate run, then activating scheduler', 'log', 'cyan')
try {
await rewardsBot.initialize()
await rewardsBot.run()
log('main', 'MAIN', '✓ Initial run completed successfully', 'log', 'green')
} catch (error) {
log('main', 'MAIN', `Initial run failed: ${error instanceof Error ? error.message : String(error)}`, 'error')
// Continue to scheduler activation even if initial run fails
}
// Initialize scheduler for future runs
scheduler = new InternalScheduler(config, async () => {
try {
await rewardsBot.initialize()
@@ -1070,13 +1083,14 @@ async function main(): Promise<void> {
// Keep process alive - scheduler handles execution
return
} else {
log('main', 'MAIN', 'Scheduler failed to start. Running one-time execution instead.', 'warn')
log('main', 'MAIN', 'Scheduler failed to start. Exiting after one-time execution.', 'warn')
scheduler = null
// Continue with one-time execution below
// Already ran once above, so just exit
return
}
}
// One-time execution (scheduling disabled or failed to start)
// One-time execution (scheduling disabled)
await rewardsBot.initialize()
await rewardsBot.run()
} catch (e) {