* Checks if the editor is visible * and that we are connected to the host * * Reload until both checks pass
()
| 321 | * Reload until both checks pass |
| 322 | */ |
| 323 | async reloadUntilEditorIsReady() { |
| 324 | this.codeServer.logger.debug("Waiting for editor to be ready...") |
| 325 | |
| 326 | const editorIsVisible = await this.isEditorVisible() |
| 327 | let reloadCount = 0 |
| 328 | |
| 329 | // Occassionally code-server timeouts in Firefox |
| 330 | // we're not sure why |
| 331 | // but usually a reload or two fixes it |
| 332 | // TODO@jsjoeio @oxy look into Firefox reconnection/timeout issues |
| 333 | while (!editorIsVisible) { |
| 334 | // When a reload happens, we want to wait for all resources to be |
| 335 | // loaded completely. Hence why we use that instead of DOMContentLoaded |
| 336 | // Read more: https://thisthat.dev/dom-content-loaded-vs-load/ |
| 337 | await this.page.waitForLoadState("load") |
| 338 | // Give it an extra second just in case it's feeling extra slow |
| 339 | await this.page.waitForTimeout(1000) |
| 340 | reloadCount += 1 |
| 341 | if (await this.isEditorVisible()) { |
| 342 | this.codeServer.logger.debug(`editor became ready after ${reloadCount} reloads`) |
| 343 | break |
| 344 | } |
| 345 | await this.page.reload() |
| 346 | } |
| 347 | |
| 348 | this.codeServer.logger.debug("Editor is ready!") |
| 349 | } |
| 350 | |
| 351 | /** |
| 352 | * Checks if the editor is visible |
no test coverage detected