mirror of
https://github.com/LightZirconite/Microsoft-Rewards-Bot.git
synced 2026-01-10 17:26:17 +00:00
fix: Update version to 2.56.15 and improve immediate task execution in scheduling logic
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -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": {
|
||||||
|
|||||||
@@ -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",
|
||||||
|
|||||||
22
src/index.ts
22
src/index.ts
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user