import NetIdleWatcher from 'chrome-remote-interface-extra/lib/network/NetworkIdleWatcher.js'NetIdleWatcher
Extends:
Monitors the HTTP requests made by a page and emits the 'network-idle' event when it has been determined the network is idle
Static Method Summary
| Static Public Methods | ||
| public static |
idlePromise(networkManager: NetworkManager, options: NetIdleOptions): Promise<void> Start monitoring the network and receive a Promise that resolves once network idle occurred or the global wait time has been reached |
|
Constructor Summary
| Public Constructor | ||
| public |
constructor(networkManager: NetworkManager, options: NetIdleOptions) |
|
Member Summary
| Private Members | ||
| private |
Flag indicating if we are in a network tracking state of not |
|
| private |
The id of the global crawler setTimeout timer |
|
| private |
The number of in-flight requests there should be before starting the network-idle timer |
|
| private |
The amount of time no new HTTP requests should be made before emitting the network-idle event |
|
| private |
The id of the setTimeout for the network-idle timer |
|
| private |
The page object of the current page the crawler is visting |
|
| private |
An array of listeners registered on the page object |
|
| private |
Set of the HTTP requests ids, used for tracking network-idle |
|
| private |
Maximum amount of time a crawler going to visit a page |
|
Method Summary
| Public Methods | ||
| public |
reqFinished(info: Response | Request) Indicate that a request has finished |
|
| public |
reqStarted(info: Request) Indicate that a request was made |
|
| public |
start() Setup the necessary listeners |
|
| Private Methods | ||
| private |
Clear all timers |
|
| private |
Emit the network-idle event |
|
| private |
Called when the global time limit was hit |
|
| private |
Called when the network idle has been determined |
|
Static Public Methods
public static idlePromise(networkManager: NetworkManager, options: NetIdleOptions): Promise<void> source
Start monitoring the network and receive a Promise that resolves once network idle occurred or the global wait time has been reached
Params:
| Name | Type | Attribute | Description |
| networkManager | NetworkManager | NetworkManager object for the page being crawled |
|
| options | NetIdleOptions |
|
Optional options to control fine tune network idle determination |
Public Constructors
public constructor(networkManager: NetworkManager, options: NetIdleOptions) source
Params:
| Name | Type | Attribute | Description |
| networkManager | NetworkManager | Page object for the page being crawled |
|
| options | NetIdleOptions |
|
Optional options to control fine tune network idle determination |
Private Members
private _idleInflight: number source
The number of in-flight requests there should be before starting the network-idle timer
private _idleTime: number source
The amount of time no new HTTP requests should be made before emitting the network-idle event
private _networkManager: NetworkManager source
The page object of the current page the crawler is visting
Public Methods
public reqFinished(info: Response | Request) source
Indicate that a request has finished
Params:
| Name | Type | Attribute | Description |
| info | Response | Request | Puppeteer Request or Response object |
public reqStarted(info: Request) source
Indicate that a request was made
Params:
| Name | Type | Attribute | Description |
| info | Request | Puppeteer Request object |
