@vpalmisano/webrtcperf 4.7.4 → 4.7.5

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vpalmisano/webrtcperf",
3
- "version": "4.7.4",
3
+ "version": "4.7.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/vpalmisano/webrtcperf.git"
@@ -55,7 +55,7 @@
55
55
  "@modelcontextprotocol/sdk": "^1.29.0",
56
56
  "@puppeteer/browsers": "^2.13.0",
57
57
  "@vpalmisano/throttler": "0.0.14",
58
- "@vpalmisano/webrtcperf-js": "^1.2.10",
58
+ "@vpalmisano/webrtcperf-js": "^1.2.11",
59
59
  "axios": "^1.15.2",
60
60
  "chalk-template": "^1.1.2",
61
61
  "change-case": "^4.1.2",
package/src/app.ts CHANGED
@@ -160,9 +160,11 @@ export class Application extends EventEmitter {
160
160
  id,
161
161
  throttleIndex,
162
162
  })
163
- session.once('stop', () => {
164
- console.warn(`Session ${id} stopped, reloading...`)
165
- setTimeout(() => this.startSession(id, spawnPeriod), spawnPeriod)
163
+ session.once('stop', (_, error) => {
164
+ if (error) {
165
+ console.warn(`Session ${id} stopped with error: ${error.message}, reloading...`)
166
+ setTimeout(() => this.startSession(id, spawnPeriod), spawnPeriod)
167
+ }
166
168
  })
167
169
  this.stats.addSession(session)
168
170
  await session.start()
package/src/session.ts CHANGED
@@ -695,7 +695,7 @@ export class Session extends EventEmitter {
695
695
  })
696
696
  } catch (err) {
697
697
  log.error(`${this.id} browser connect error: ${(err as Error).stack}`)
698
- return this.stop()
698
+ return this.stop(err as Error)
699
699
  }
700
700
  } else {
701
701
  // run a browser instance locally
@@ -753,7 +753,7 @@ export class Session extends EventEmitter {
753
753
  log.debug(`[session ${this.id}] Using chrome version: ${version}`)
754
754
  } catch (err) {
755
755
  log.error(`[session ${this.id}] Browser launch error: ${(err as Error).stack}`)
756
- return this.stop()
756
+ return this.stop(err as Error)
757
757
  }
758
758
  }
759
759
 
@@ -765,7 +765,7 @@ export class Session extends EventEmitter {
765
765
 
766
766
  this.browser.once('disconnected', () => {
767
767
  log.debug('browser disconnected')
768
- return this.stop()
768
+ return this.stop(new Error('Browser disconnected'))
769
769
  })
770
770
 
771
771
  // get GPU infos from chrome://gpu page
@@ -925,6 +925,8 @@ webrtcperf.config.MEDIA_URL = webrtcperf_getServerUrl("cache/${path.basename(thi
925
925
  ),
926
926
  )
927
927
 
928
+ await page.exposeFunction('webrtcperf_stopSession', () => this.stop())
929
+
928
930
  // Export config to page.
929
931
  let cmd = this.setupPageCmd(index, tabIndex, url)
930
932
  if (this.localStorage) {
@@ -1951,12 +1953,12 @@ mv ${logFilePath}.tmp ${logFilePath};
1951
1953
  /**
1952
1954
  * stop
1953
1955
  */
1954
- async stop(): Promise<void> {
1956
+ async stop(error?: Error): Promise<void> {
1955
1957
  if (!this.running) {
1956
1958
  return
1957
1959
  }
1958
1960
  this.running = false
1959
- log.debug(`${this.id} stop`)
1961
+ log.debug(`${this.id} stop${error ? ` (error: ${error.message})` : ''}`)
1960
1962
 
1961
1963
  if (this.stopPortForwarder) {
1962
1964
  this.stopPortForwarder()
@@ -2012,7 +2014,7 @@ mv ${logFilePath}.tmp ${logFilePath};
2012
2014
  this.browser = undefined
2013
2015
  }
2014
2016
 
2015
- this.emit('stop', this.id)
2017
+ this.emit('stop', this.id, error)
2016
2018
  }
2017
2019
 
2018
2020
  /**