fix(vue): бесконечная реактивная петля в ResourceCategoryTree — фриз Настройки→Опции (#546) - #547
Merged
Merged
Conversation
watch(() => props.modelValue) called ensureLockedChecked() unconditionally, which emits update:modelValue with a fresh array. The parent's v-model echoes it straight back into the prop, retriggering the watch — an infinite recursive loop (Vue: "Maximum recursive updates exceeded") that froze Settings→Options and any page using the tree. The single /api/mgr/options request showed as pending only because the frozen main thread never processed the (instant, 0.006s) reply. Emit back only when locked enforcement actually adds an ID the parent lacks, so the watch no longer echoes the value it just received. Verified in isolation: 1 emit instead of an infinite loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #546
Проблема
Админка → Настройки → «Опции» намертво виснет при открытии. В Network единственный
GET /api/mgr/optionsвисит вpending.Причина — бесконечная реактивная петля
ResourceCategoryTree.vue:watch(() => props.modelValue, …, { deep:true })безусловно звалensureLockedChecked()→emitSelection()эмититupdate:modelValueновым массивом → родитель (OptionsGrid.selectedCategoriesчерезOptionCategoryTreev-model) обновляет модель → ссылка меняется →watchснова → бесконечно.Петля реактивная (микротаски) — пожирает главный поток. Поэтому страница фризится, а одиночный
/api/mgr/optionsвиситpending: замороженный браузер не может обработать уже пришедший ответ.Доказательства (воспроизведено, не гипотеза)
Maximum recursive updates exceeded(guard Vue).OptionsController::getListв CLI — 0.006с (total=21, results=20), БД чиста (MariaDB, 21 строка).Регрессия из
6d7a13871.Решение (проверено на стенде)
watch(modelValue)не эхо-эмитит полученное значение —emitSelection()только когда locked-принуждение реально добавило ID, которого у родителя нет:С guard'ом на изолированном стенде — 1 эмит вместо бесконечного цикла; locked-семантика сохранена.
Радиус
Тот же
ResourceCategoryTree— вProductCategoriesTab(карточка товара → Категории) иCategoryOptionsTab. Фикс закрывает петлю для всех потребителей.Проверка
npm run build✅.