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
- Enable a mod manually in the Mods tab.
- Save it into a Mod Profile.
- Attach that Mod Profile to a Launch Profile.
- Launch — the mod ends up disabled on startup.
Environment
- Weave-Manager: 1.0.1 (commit 6cd775c)
- OS: Windows 11 25H2
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
loadModProfileinsrc/scripts/components.tsiterates withforEachand does not await the inner
toggleMod(mod)calls:Because
forEachcan't be awaited andtoggleMod's promise is discarded,loadModProfilereturns (and the caller'sawait loadModProfile(...)resolves) before the underlying file renames actually finish. When
launchProfile()inLaunchProfiles.svelteimmediately proceeds toinvoke("launch", ...), the mod files can still be mid-rename or intheir pre-toggle
.disabledstate, so mods that should be enabled getlaunched as disabled (or vice versa).
Fix
Iterate with a
for...ofloop and await each toggle:Repro steps
Environment