commit 657b4c037cb309f947a8083d7572de1b743fca5a
parent 17cd600fd4e17eb1ab2cc0d01dbd288507d46357
Author: Julian Piribauer <julian.piribauer@gmail.com>
Date: Sat, 9 May 2026 17:58:57 +0000
Add cycle safeguard to generation-ranking loop
Bounds the while(changed) iteration to people.length * 4 to prevent
an infinite loop if parent links contain a cycle (e.g. bad data entry
where a grandparent was accidentally marked as a child).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat:
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/static/app.js b/static/app.js
@@ -227,7 +227,8 @@ function computeLayout({ people, partnerships, parentLinks }, opts = {}) {
// then push children down accordingly. Must be one combined loop because
// moving a child up may require moving that child's root-partner up too.
let changed = true;
- while (changed) {
+ let _safetyIter = 0;
+ while (changed && _safetyIter++ < people.length * 4) {
changed = false;
for (const ps of partnerships) {
const g1 = gen[ps.person1_id], g2 = gen[ps.person2_id];