@vpalmisano/webrtcperf 4.4.3 → 4.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1096,11 +1096,21 @@ Object.defineProperty(window.screen.orientation, 'type', { value: 'landscape-pri
1096
1096
  }
1097
1097
  // add to pages map
1098
1098
  this.pages.set(index, page);
1099
+ // Handle network internal throttling.
1099
1100
  if (this.throttleIndex > -1 && (process.platform !== 'linux' || this.useBrowserThrottling)) {
1100
- await this.applyNetworkThrottling(pageCDPSession);
1101
- throttler_1.throttleNotifier.on('change', async () => {
1102
- await this.applyNetworkThrottling(pageCDPSession);
1103
- });
1101
+ const onThrottleChange = async () => {
1102
+ if (page.isClosed())
1103
+ return;
1104
+ try {
1105
+ await this.applyNetworkThrottling(pageCDPSession);
1106
+ }
1107
+ catch (err) {
1108
+ log.error(`applyNetworkThrottling error: ${err.stack}`);
1109
+ }
1110
+ };
1111
+ await onThrottleChange();
1112
+ throttler_1.throttleNotifier.on('change', onThrottleChange);
1113
+ page.once('close', () => throttler_1.throttleNotifier.off('change', onThrottleChange));
1104
1114
  }
1105
1115
  log.debug(`Page ${index + 1} "${url}" loaded in ${(Date.now() - pageLoadTime) / 1000}s`);
1106
1116
  for (let i = 0; i < this.evaluateAfter.length; i++) {