(err: Error)
| 82 | } |
| 83 | |
| 84 | onError(err: Error) { |
| 85 | if (this.retryCounter < MAX_RETRIES) { |
| 86 | if (this.server) { // Try and close / remove server first |
| 87 | try { |
| 88 | this.server.close(); |
| 89 | } catch {/** Ignore closure errors */} finally { |
| 90 | this.server = undefined; |
| 91 | } |
| 92 | } |
| 93 | this.retryCounter++; |
| 94 | setTimeout(() => { // Sleep then try and connect again |
| 95 | this.listen(0,0, this.host) |
| 96 | .catch(this.onError); // If failed to open, keep trying until we get there! |
| 97 | }, 1500); |
| 98 | } |
| 99 | } |
| 100 | /** Close the server. */ |
| 101 | public close(): Promise<void> { |
| 102 | return new Promise((resolve, reject) => { |
no test coverage detected