Skip to content

fix(ProjectService): Empty lesson that transitions to itself overflows the stack - #2349

Merged
hirokiterashima merged 1 commit into
WISE-Community:developfrom
Isaries:fix/empty-lesson-transition-loop
Oct 21, 2026
Merged

hirokiterashima merged 1 commit into
WISE-Community:developfrom
Isaries:fix/empty-lesson-transition-loop

Conversation

@Isaries

@Isaries Isaries commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

getLessonPaths() handles an empty lesson (no startId) by following the lesson's own transitions, and it does so without checking pathSoFar. A lesson whose transition points back to a lesson already on the path, including itself, therefore recurses until RangeError: Maximum call stack size exceeded.

getStepPaths() already handles this case: when pathSoFar contains the target it ends the path instead of following the transition. Empty lessons were the one path without that check.

Because parseProject() calls getAllPaths() through getBranches(), the error is thrown whenever the unit is loaded, for authoring and for preview alike. One bad transition makes the whole unit unopenable, including the authoring view that would be needed to fix it. The only remaining options are the recovery view or editing project.json on disk.

A self-transition like this is what pressing Enter in the add lesson view currently produces; #2348 fixes that cause. This PR makes units already saved in that state open again, so the extra lesson can be deleted in the authoring tool.

Changes

  • In getLessonPaths(), a transition whose target is already in pathSoFar ends the path at the lesson, matching getStepPaths().

Test

  • New case in projectService.spec.ts under getAllPaths(): an empty lesson that transitions to itself yields ['node1', 'node2', 'group3']. Against the current develop, it fails with RangeError: Maximum call stack size exceeded.

…s the stack

getLessonPaths() followed an empty lesson's transitions without checking
the path so far, so a lesson that transitions to itself recursed until
the stack overflowed. Parsing runs whenever a unit is opened for
authoring or preview, so one bad transition made the whole unit
unopenable, including the authoring view needed to repair it. Steps
already end the path on a loop; do the same for empty lessons.

@Aaron-Detre Aaron-Detre left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@hirokiterashima
hirokiterashima merged commit 2160c5b into WISE-Community:develop Oct 21, 2026
3 of 4 checks passed
@hirokiterashima

Copy link
Copy Markdown
Member

🎉 This PR is included in version 5.248.2 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants