MCPcopy Index your code
hub / github.com/coder/code-server / reloadUntilEditorIsReady

Method reloadUntilEditorIsReady

test/e2e/models/CodeServer.ts:323–349  ·  view source on GitHub ↗

* Checks if the editor is visible * and that we are connected to the host * * Reload until both checks pass

()

Source from the content-addressed store, hash-verified

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

Callers 2

navigateMethod · 0.95
login.test.tsFile · 0.80

Calls 1

isEditorVisibleMethod · 0.95

Tested by

no test coverage detected