Related to #65 — same report, but a separate bug from the login-wall issue #65 covers (fixed in #68). Later in that run, tests started failing with:
[Bot] SkyGalaxis error (1 so far): Failed to obtain profile data for SkyGalaxis, does the account own minecraft?
Root cause
Every test gets its own bot connection (Session.createBot() → mineflayer.createBot()) — by design since #53, independent state per test. For a microsoft-auth account, that means a full Microsoft auth handshake on every single test.
Inside minecraft-protocol's microsoftAuth.authenticate() (via prismarine-auth's MicrosoftAuthFlow.getMinecraftJavaToken):
- the actual MS/Xbox token is already disk-cached (
mca.verifyTokens() reuses it, no network call when still valid);
- but
fetchProfile() and fetchCertificates() run unconditionally on every connect, no caching at all, straight to api.minecraftservices.com.
Run enough tests back to back and one of those calls eventually fails — rate limit, or just a transient blip — and microsoftAuth.js throws Failed to obtain profile data for ${username}, does the account own minecraft?, even though the account itself is fine.
Proposed fix
minecraft-protocol's auth option accepts a function, not just the built-in strings (auth?: 'mojang' | 'microsoft' | 'offline' | ((client, options) => void)). A custom auth function can cache profile + certificates per account username in memory, for the life of the run process, and fetch them once instead of once per test.
This only touches the Microsoft handshake, not the bot/game connection — every test still gets a fresh mineflayer.createBot(), a fresh join, fresh in-game state. No state carryover, so it doesn't reopen #53.
Related to #65 — same report, but a separate bug from the login-wall issue #65 covers (fixed in #68). Later in that run, tests started failing with:
Root cause
Every test gets its own bot connection (
Session.createBot()→mineflayer.createBot()) — by design since #53, independent state per test. For amicrosoft-auth account, that means a full Microsoft auth handshake on every single test.Inside
minecraft-protocol'smicrosoftAuth.authenticate()(viaprismarine-auth'sMicrosoftAuthFlow.getMinecraftJavaToken):mca.verifyTokens()reuses it, no network call when still valid);fetchProfile()andfetchCertificates()run unconditionally on every connect, no caching at all, straight toapi.minecraftservices.com.Run enough tests back to back and one of those calls eventually fails — rate limit, or just a transient blip — and
microsoftAuth.jsthrowsFailed to obtain profile data for ${username}, does the account own minecraft?, even though the account itself is fine.Proposed fix
minecraft-protocol'sauthoption accepts a function, not just the built-in strings (auth?: 'mojang' | 'microsoft' | 'offline' | ((client, options) => void)). A custom auth function can cacheprofile+certificatesper account username in memory, for the life of the run process, and fetch them once instead of once per test.This only touches the Microsoft handshake, not the bot/game connection — every test still gets a fresh
mineflayer.createBot(), a fresh join, fresh in-game state. No state carryover, so it doesn't reopen #53.