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

6
package-lock.json generated
View File

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

View File

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

View File

@@ -1051,7 +1051,20 @@ async function main(): Promise<void> {
// Check if scheduling is enabled // Check if scheduling is enabled
if (config.scheduling?.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 () => { scheduler = new InternalScheduler(config, async () => {
try { try {
await rewardsBot.initialize() await rewardsBot.initialize()
@@ -1070,13 +1083,14 @@ async function main(): Promise<void> {
// Keep process alive - scheduler handles execution // Keep process alive - scheduler handles execution
return return
} else { } 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 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.initialize()
await rewardsBot.run() await rewardsBot.run()
} catch (e) { } catch (e) {