MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / ensureSocketInitialized

Function ensureSocketInitialized

source code/utils/tmuxSocket.ts:210–248  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

208 * Bash commands will run without tmux isolation.
209 */
210export async function ensureSocketInitialized(): Promise<void> {
211 // Already initialized
212 if (isSocketInitialized()) {
213 return
214 }
215
216 // Check if tmux is available before trying to use it
217 const available = await checkTmuxAvailable()
218 if (!available) {
219 return
220 }
221
222 // Another call is already initializing - wait for it but don't propagate errors
223 // The original caller handles the error and sets up graceful degradation
224 if (isInitializing && initPromise) {
225 try {
226 await initPromise
227 } catch {
228 // Ignore - the original caller logs the error
229 }
230 return
231 }
232
233 isInitializing = true
234 initPromise = doInitialize()
235
236 try {
237 await initPromise
238 } catch (error) {
239 // Log error but don't throw - graceful degradation
240 const err = toError(error)
241 logError(err)
242 logForDebugging(
243 `[Socket] Failed to initialize tmux socket: ${err.message}. Tmux isolation will be disabled.`,
244 )
245 } finally {
246 isInitializing = false
247 }
248}
249
250/**
251 * Kills the tmux server for Claude's isolated socket.

Callers 1

getEnvironmentOverridesFunction · 0.85

Calls 6

isSocketInitializedFunction · 0.85
checkTmuxAvailableFunction · 0.85
doInitializeFunction · 0.85
toErrorFunction · 0.85
logForDebuggingFunction · 0.85
logErrorFunction · 0.70

Tested by

no test coverage detected