MCPcopy
hub / github.com/coder/mux / ensureProvisioningSession

Method ensureProvisioningSession

src/node/services/coderService.ts:536–560  ·  view source on GitHub ↗
(workspaceName: string)

Source from the content-addressed store, hash-verified

534 }
535
536 async ensureProvisioningSession(workspaceName: string): Promise<CoderApiSession> {
537 const existing = this.provisioningSessions.get(workspaceName);
538 if (existing) {
539 return existing;
540 }
541
542 const pending = this.provisioningSessionPromises.get(workspaceName);
543 if (pending) {
544 return pending;
545 }
546
547 const tokenName = `mux-${workspaceName}-${Date.now().toString(36)}`;
548 const sessionPromise = this.createApiSession(tokenName)
549 .then((session) => {
550 this.provisioningSessions.set(workspaceName, session);
551 this.provisioningSessionPromises.delete(workspaceName);
552 return session;
553 })
554 .catch((error: unknown) => {
555 this.provisioningSessionPromises.delete(workspaceName);
556 throw error;
557 });
558 this.provisioningSessionPromises.set(workspaceName, sessionPromise);
559 return sessionPromise;
560 }
561
562 takeProvisioningSession(workspaceName: string): CoderApiSession | undefined {
563 const session = this.provisioningSessions.get(workspaceName);

Callers 2

finalizeConfigMethod · 0.80

Calls 4

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

Tested by

no test coverage detected