From dfc9b823a40989eafe53740488706cff1023bdd1 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnier Date: Thu, 4 Jun 2026 23:23:11 +0200 Subject: [PATCH] fix(hooks): remove auto editMode flag setting to prevent phase errors The createActor hook was causing 'ActiveEffect application phase already completed' errors because setFlag() triggers actor updates which call prepareData() -> prepareEmbeddedDocuments() -> applyActiveEffects(). Even with setTimeout delays, the error persisted. The cleanest solution is to remove the auto-setting entirely. Users can enable edit mode manually via the checkbox in the character sheet (which is preserved). This prevents the error on: - Character sheet profile editing - Creature sheet creation - Group sheet profile editing Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- module/system/hooks.mjs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/module/system/hooks.mjs b/module/system/hooks.mjs index 7d77bf3..7f32555 100644 --- a/module/system/hooks.mjs +++ b/module/system/hooks.mjs @@ -147,17 +147,10 @@ export const registerHooks = function () { }*/ } }); - Hooks.on("createActor", async function (actor, options, id) { - // Delay flag setting to avoid the "phase already completed" error - // When an actor is created, it goes through data preparation which applies effects. - // If we call setFlag() immediately, it triggers updateActor -> prepareData -> - // prepareEmbeddedDocuments() which tries to apply effects again, causing the error. - // By using setTimeout with 0ms, we defer the flag setting until after the current - // preparation cycle is complete. - setTimeout(() => { - actor.setFlag("world", "editMode", true).catch(err => { - console.error("Vermine2047 | Failed to set editMode flag:", err); - }); - }, 0); - }) + // Note: editMode flag is no longer auto-set on actor creation to avoid + // "ActiveEffect application phase already completed" errors. + // Users can enable edit mode manually via the checkbox in the character sheet. + // Hooks.on("createActor", async function (actor, options, id) { + // actor.setFlag("world", "editMode", true); + // }) } \ No newline at end of file