Home Reference Source
public class | since chrome-remote-interface-extra | source

NetIdleWatcher

Extends:

EventEmitter → NetIdleWatcher

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

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:

NameTypeAttributeDescription
networkManager NetworkManager

NetworkManager object for the page being crawled

options NetIdleOptions
  • optional
  • default: {}
  • nullable: true

Optional options to control fine tune network idle determination

Return:

Promise<void>

Public Constructors

public constructor(networkManager: NetworkManager, options: NetIdleOptions) source

Params:

NameTypeAttributeDescription
networkManager NetworkManager

Page object for the page being crawled

options NetIdleOptions
  • optional
  • default: {}
  • nullable: true

Optional options to control fine tune network idle determination

Private Members

private _doneTimers: boolean source

Flag indicating if we are in a network tracking state of not

private _globalWaitTimer: number source

The id of the global crawler setTimeout timer

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 _idleTimer: number source

The id of the setTimeout for the network-idle timer

private _networkManager: NetworkManager source

The page object of the current page the crawler is visting

private _pageListenrs: Object[] source

An array of listeners registered on the page object

private _requestIds: Set<string> source

Set of the HTTP requests ids, used for tracking network-idle

private _timeout: number source

Maximum amount of time a crawler going to visit a page

Public Methods

public reqFinished(info: Response | Request) source

Indicate that a request has finished

Params:

NameTypeAttributeDescription
info Response | Request

Puppeteer Request or Response object

public reqStarted(info: Request) source

Indicate that a request was made

Params:

NameTypeAttributeDescription
info Request

Puppeteer Request object

public start() source

Setup the necessary listeners

Private Methods

private _clearTimers() source

Clear all timers

private _emitNetIdle() source

Emit the network-idle event

private _globalNetworkTimeout() source

Called when the global time limit was hit

private _networkIdled() source

Called when the network idle has been determined