How Infinite Loops Are Prevented
Rihario detects infinite loops and prevents exploration from getting stuck. Safety guards monitor for redirect loops, repeated actions, and stuck states. When detected, exploration stops and reports the loop so you know what happened.
What Is an Infinite Loop?
An infinite loop in web testing means:
- Redirect loop - Page A redirects to Page B, which redirects back to Page A
- Repeated actions - Same action performed multiple times without progress
- Stuck state - Exploration stuck on same page, clicking same elements repeatedly
- Circular navigation - Navigating in circles without making progress
How Detection Works
1. Page Visit Tracking
Rihario tracks which pages have been visited:
- Maintains a list of visited URLs
- Counts how many times each URL is visited
- Flags when same URL visited multiple times in short period
2. Action Pattern Detection
Monitors action patterns:
- Tracks sequence of actions
- Detects when same sequence repeats
- Flags repeated patterns as potential loops
3. Progress Monitoring
Checks if exploration is making progress:
- Monitors if new pages are being discovered
- Checks if new elements are being found
- Detects if exploration is stuck in same state
4. Redirect Loop Detection
Specifically monitors redirects:
- Tracks redirect chains
- Detects when redirects form a cycle
- Stops immediately when loop detected
Types of Loops Detected
Redirect Loops
Action Loops
Navigation Loops
What Happens When a Loop Is Detected
Immediate Stop
When a loop is detected:
- Exploration stops immediately
- Loop is reported in results
- Status shows what type of loop was detected
- You can see where the loop occurred
Loop Reporting
Results show:
- Loop type - Redirect loop, action loop, navigation loop
- Where it occurred - Which step or page
- Pattern - What was repeating
- Evidence - Screenshots and logs showing the loop
Example Loop Report
Thresholds
Loops are detected based on thresholds:
- Same URL visited 5+ times - Potential redirect loop
- Same action repeated 5+ times - Potential action loop
- No new pages in 10 steps - Potential navigation loop
- Redirect chain > 10 redirects - Potential redirect loop
These thresholds balance catching loops while allowing legitimate repetition (like pagination).
False Positives
Sometimes legitimate behaviors can look like loops:
- Pagination - Clicking through pages might look like a loop
- Refresh scenarios - Pages that refresh after actions
- Multi-step flows - Going back and forth in wizards
Rihario tries to distinguish loops from legitimate repetition, but may occasionally false positive. Review loop reports to verify they're actual problems.
Common Causes of Loops
1. Broken Redirects
Your app has a redirect bug:
- Page A redirects to Page B incorrectly
- Page B redirects back to Page A
- Creates infinite redirect loop
This is actually a bug in your app - Rihario found a real problem.
2. Authentication Issues
Auth logic causes redirects:
- Protected page redirects to login
- Login redirects back to protected page
- Creates loop if session invalid
3. Form Submission Issues
Forms that don't handle submission correctly:
- Form submits but doesn't progress
- Page reloads to same form
- Repeated submission creates loop
How to Fix Loops
If Loop Is a Bug
If Rihario detected a real loop in your app:
- Review the loop report to understand the pattern
- Fix the redirect logic or form handling
- Test manually to verify fix
- Re-run Rihario exploration
If Loop Is False Positive
If the "loop" is actually legitimate behavior:
- Ignore the loop detection
- Exploration stopped early, but that's okay
- Consider if the legitimate behavior could be improved
Preventing Loops in Your App
To avoid loops:
- Fix redirect logic - Ensure redirects don't create cycles
- Handle form errors - Don't reload forms on successful submission
- Session management - Ensure auth redirects don't loop
- Error handling - Prevent errors from causing redirect loops