MCPcopy Create free account
hub / github.com/coder/mux / ensureLoaded

Method ensureLoaded

src/node/services/devToolsService.ts:396–420  ·  view source on GitHub ↗
(workspaceId: string)

Source from the content-addressed store, hash-verified

394 }
395
396 private async ensureLoaded(workspaceId: string): Promise<void> {
397 const data = this.getOrCreateWorkspaceData(workspaceId);
398 if (data.loaded) {
399 return;
400 }
401
402 // Serialize concurrent loads for the same workspace: if another call is already
403 // loading this workspace, await its promise instead of starting a second load.
404 // This prevents duplicate disk reads and — critically — prevents stale-step
405 // finalization from running while a concurrent request has a legitimate
406 // in-progress step.
407 const existingPromise = this.loadingPromises.get(workspaceId);
408 if (existingPromise) {
409 await existingPromise;
410 return;
411 }
412
413 const loadPromise = this.loadFromDisk(workspaceId, data);
414 this.loadingPromises.set(workspaceId, loadPromise);
415 try {
416 await loadPromise;
417 } finally {
418 this.loadingPromises.delete(workspaceId);
419 }
420 }
421
422 private async loadFromDisk(workspaceId: string, data: WorkspaceData): Promise<void> {
423 const filePath = this.getSessionFilePath(workspaceId);

Callers 6

createRunMethod · 0.95
createStepMethod · 0.95
updateStepMethod · 0.95
finalizeStaleStepsMethod · 0.95
getRunsMethod · 0.95
getRunWithStepsMethod · 0.95

Calls 5

loadFromDiskMethod · 0.95
setMethod · 0.80
getMethod · 0.65
deleteMethod · 0.45

Tested by

no test coverage detected