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

Method startStartupRecovery

src/node/services/workspaceService.ts:2648–2690  ·  view source on GitHub ↗

* Run startup recovery without permanently caching a session for every workspace. * Only promote the temporary session if recovery leaves background activity alive.

(workspaceId: string)

Source from the content-addressed store, hash-verified

2646 * Only promote the temporary session if recovery leaves background activity alive.
2647 */
2648 private startStartupRecovery(workspaceId: string): void {
2649 const trimmed = workspaceId.trim();
2650 if (!trimmed) {
2651 return;
2652 }
2653
2654 const existingSession =
2655 this.sessions.get(trimmed) ?? this.transientStartupRecoverySessions.get(trimmed);
2656 if (existingSession) {
2657 existingSession.scheduleStartupRecovery();
2658 return;
2659 }
2660
2661 const session = this.createSession(trimmed);
2662 this.transientStartupRecoverySessions.set(trimmed, session);
2663
2664 void session
2665 .runStartupRecovery()
2666 .then(() => {
2667 if (this.transientStartupRecoverySessions.get(trimmed) !== session) {
2668 return;
2669 }
2670
2671 this.transientStartupRecoverySessions.delete(trimmed);
2672 if (session.shouldRetainAfterStartupRecovery()) {
2673 this.registerSession(trimmed, session);
2674 return;
2675 }
2676
2677 session.dispose();
2678 })
2679 .catch((error) => {
2680 if (this.transientStartupRecoverySessions.get(trimmed) === session) {
2681 this.transientStartupRecoverySessions.delete(trimmed);
2682 session.dispose();
2683 }
2684
2685 log.warn("Failed to run startup recovery for workspace", {
2686 workspaceId: trimmed,
2687 error: getErrorMessage(error),
2688 });
2689 });
2690 }
2691
2692 private createSession(workspaceId: string): AgentSession {
2693 return new AgentSession({

Callers 2

initializeMethod · 0.95

Calls 10

createSessionMethod · 0.95
registerSessionMethod · 0.95
getErrorMessageFunction · 0.90
setMethod · 0.80
runStartupRecoveryMethod · 0.80
getMethod · 0.65
disposeMethod · 0.65
deleteMethod · 0.45

Tested by

no test coverage detected