Skip to content

fix package scripts, server join fallback logic, and reconnect timer leaks - #9

Open
Spagles wants to merge 3 commits into
albertodrake:mainfrom
Spagles:main
Open

fix package scripts, server join fallback logic, and reconnect timer leaks#9
Spagles wants to merge 3 commits into
albertodrake:mainfrom
Spagles:main

Conversation

@Spagles

@Spagles Spagles commented Aug 15, 2026

Copy link
Copy Markdown
  • Fixed package.json entry points: Updated main, scripts.start, and scripts.dev from bot.js to bot-authme-first.js. bot.js didn't exist in the repository, so running npm start failed immediately with a Cannot find module error.
  • Fixed server join fallback execution: serverJoined was previously set to true immediately when sending the /server survival command. Because it was set to true right away, the 10-second timeout condition if (authmeCompleted && !serverJoined) could never evaluate to true. If a server didn't send a chat message matching the expected join keywords, the fallback would never trigger and the bot would get stuck in the lobby without starting AFK tasks. We now only set serverJoined = true once chat confirms the join or when the 10-second fallback timer elapses.
  • Debounced auto-reconnect on kick: When kicked, Mineflayer emits both 'kicked' and 'end' events. Because both handlers scheduled createBot() after a delay, every kick spawned two bots connecting simultaneously with the same username, triggering an infinite reconnect/kick loop. Reconnects are now debounced with a single timeout guard (scheduleReconnect).
  • Cleaned up intervals on reconnect, respawn, and shutdown: startAntiAFK() and startChatMessages() created new setInterval timers on every call without clearing existing ones. Over multiple reconnections or deaths, these timers accumulated in the event loop and performed duplicate actions against the bot instance. Interval handles are now stored and cleared properly before creating new loops and on graceful shutdown (SIGINT/SIGTERM).

@Programmeur2030 Programmeur2030 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

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