* This is the workhorse function for all kinds of status queries on port:localhost * * @param opts
(opts: PortStatusArgs)
| 303 | * @param opts |
| 304 | */ |
| 305 | protected static waitForPortStatusEx(opts: PortStatusArgs): Promise<void> { |
| 306 | opts.startTimeMs = Date.now(); |
| 307 | const functor = opts.checkLocalHostAliases ? TcpPortScanner.isPortInUseEx : TcpPortScanner.isPortInUse; |
| 308 | return new Promise(function tryAgain(resolve, reject) { |
| 309 | functor(opts.port, opts.host, null) |
| 310 | .then((inUse) => { |
| 311 | // ConsoleLog(`${functor.name} returned ${inUse}`) |
| 312 | if (inUse === opts.desiredStatus) { // status match |
| 313 | return resolve(); |
| 314 | } else { |
| 315 | throw new Error('tryagain'); |
| 316 | } |
| 317 | }).catch((e) => { |
| 318 | if (e.message !== 'tryagain') { |
| 319 | return reject(e); |
| 320 | } else { |
| 321 | const t = Date.now() - opts.startTimeMs; |
| 322 | if (t < opts.timeOutMs) { |
| 323 | // ConsoleLog(`Setting timeout for ${opts.retryTimeMs}ms, curTime = ${t}ms`); |
| 324 | setTimeout(() => { |
| 325 | tryAgain(resolve, reject); |
| 326 | }, opts.retryTimeMs); |
| 327 | } else { |
| 328 | return reject(new Error('timeout')); |
| 329 | } |
| 330 | } |
| 331 | }); |
| 332 | }); |
| 333 | } |
| 334 | |
| 335 | /** |
| 336 | * Wait for particular port status. We always do a minium of one try regardless of timeouts, so setting a timeout |
no outgoing calls
no test coverage detected