IdleMonitorService
TheIdleMonitorService hooks into Angular’s Zone.js to detect when your application has finished rendering and is idle, signaling to Scully’s Puppeteer instance that the page is ready to be captured.
Overview
This service is critical for Scully’s rendering process. It monitors:- Ongoing HTTP requests
- Asynchronous tasks
- Zone.js macro tasks
- Custom rendering completion signals
Installation
The service is automatically provided when you importScullyLibModule:
How It Works
Automatic Idle Detection
By default, the service automatically monitors Zone.js tasks:- AngularInitialized event is fired when the service initializes
- Monitors all macro tasks (especially XMLHttpRequests)
- When all tasks complete, waits 250ms for final rendering
- Fires AngularReady event, signaling Scully to capture the page
- If not idle within 30 seconds, fires AngularTimeout event
Browser Events
The service dispatches three custom events:Observable
idle$
true when the application becomes idle, false when it becomes active again.
Example:
Methods
fireManualMyAppReadyEvent()
AngularReady event. Use this when you have custom loading logic that Zone.js doesn’t capture.
Returns: Promise that resolves to true when the event is dispatched.
Example:
init()
setPupeteerTimeoutValue()
Configuration
Global Configuration
Configure the service behavior throughScullyLibModule.forRoot():
Configuration Options
false(default): Only monitors during Scully renderingtrue: Monitors in all environments (useful for debugging)
false(default): Automatic Zone.js monitoringtrue: You must callfireManualMyAppReadyEvent()manually
Manual Idle Control
Application-Wide Manual Control
Disable automatic detection and take full control:Per-Route Manual Control
Enable manual idle checking for specific routes:Advanced Usage
Debugging Idle Detection
Waiting for External Scripts
Troubleshooting
Content Missing in Rendered Pages
If your content is missing from Scully’s rendered pages:- Enable manual idle control:
- Call
fireManualMyAppReadyEvent()after content loads:
Pages Timing Out
If you see “AngularTimeout” warnings:- Check for infinite observables:
- Increase timeout for slow pages:

