Skip to content

[v3] Repeated Microsoft profile/certificate fetch causes intermittent auth failures in long runs #69

Description

@monikon22

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions