You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Express allows a router to be mounted on itself (directly or indirectly). The registration succeeds, but any request that traverses the cycle hangs indefinitely causing a stack overflow. The issue is tricky to spot because nothing happens at startup.
Detecting this setup when app.use / router.use is called and emitting a warning would make the problem much easier to diagnose, while keeping behavior unchanged.
Hit GET /cycle the request never completes and memory usage grows until the process terminates.
The issue is easy to introduce in complex router hierarchies and incredibly hard to debug once it manifests. Emitting a warning when such a circular mount is detected would reduce the time needed to locate the offending setup, and we can consider turning this into a thrown error in the next major version (v6).
This issue is actually in the router package (pillarjs/router) which Express depends on. I've addressed it with cycle detection that emits a warning when a router is mounted on itself: pillarjs/router#183
Activity
aprici7y commentedon Oct 7, 2025
i would like to work on this one
Add router cycle detection to prevent infinite loops
aprici7y commentedon Oct 7, 2025
This issue is actually in the router package (pillarjs/router) which Express depends on. I've addressed it with cycle detection that emits a warning when a router is mounted on itself: pillarjs/router#183
ganeshbhagwat123924 commentedon Oct 9, 2025