Skip to content

Mod profiles silently disable mods on launch due to un-awaited toggleMod calls in loadModProfile #24

Description

@Hryday06

Description

When a Launch Profile has a Mod Profile attached, launching it can end up
disabling mods that were just manually enabled and saved into that mod
profile — even mods actually present in profile.mods.

Root cause

loadModProfile in src/scripts/components.ts iterates with forEach
and does not await the inner toggleMod(mod) calls:

export async function loadModProfile(profile: ModProfile) {
    const allMods = get<Mod[]>(modList)
    allMods.forEach((mod) => {
        if (profile.mods.find((profileMod) => profileMod.file_name === mod.file_name) && mod.disabled)
            toggleMod(mod)
        else if (!mod.disabled) {
            toggleMod(mod)
        }
    })
}

Because forEach can't be awaited and toggleMod's promise is discarded,
loadModProfile returns (and the caller's await loadModProfile(...)
resolves) before the underlying file renames actually finish. When
launchProfile() in LaunchProfiles.svelte immediately proceeds to
invoke("launch", ...), the mod files can still be mid-rename or in
their pre-toggle .disabled state, so mods that should be enabled get
launched as disabled (or vice versa).

Fix

Iterate with a for...of loop and await each toggle:

export async function loadModProfile(profile: ModProfile) {
    const allMods = get<Mod[]>(modList)
    for (const mod of allMods) {
        if (profile.mods.find((profileMod) => profileMod.file_name === mod.file_name) && mod.disabled)
            await toggleMod(mod)
        else if (!mod.disabled) {
            await toggleMod(mod)
        }
    }
}

Repro steps

  1. Enable a mod manually in the Mods tab.
  2. Save it into a Mod Profile.
  3. Attach that Mod Profile to a Launch Profile.
  4. Launch — the mod ends up disabled on startup.

Environment

  • Weave-Manager: 1.0.1 (commit 6cd775c)
  • OS: Windows 11 25H2

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions