MCPcopy Index your code
hub / github.com/codeaashu/claude-code / gracefulShutdownSync

Function gracefulShutdownSync

src/utils/gracefulShutdown.ts:336–359  ·  view source on GitHub ↗
(
  exitCode = 0,
  reason: ExitReason = 'other',
  options?: {
    getAppState?: () => AppState
    setAppState?: (f: (prev: AppState) => AppState) => void
  },
)

Source from the content-addressed store, hash-verified

334})
335
336export function gracefulShutdownSync(
337 exitCode = 0,
338 reason: ExitReason = 'other',
339 options?: {
340 getAppState?: () => AppState
341 setAppState?: (f: (prev: AppState) => AppState) => void
342 },
343): void {
344 // Set the exit code that will be used when process naturally exits. Note that we do it
345 // here inside the sync version too so that it is possible to determine if
346 // gracefulShutdownSync was called by checking process.exitCode.
347 process.exitCode = exitCode
348
349 pendingShutdown = gracefulShutdown(exitCode, reason, options)
350 .catch(error => {
351 logForDebugging(`Graceful shutdown failed: ${error}`, { level: 'error' })
352 cleanupTerminalModes()
353 printResumeHint()
354 forceExit(exitCode)
355 })
356 // Prevent unhandled rejection: forceExit re-throws in test mode,
357 // which would escape the .catch() handler above as a new rejection.
358 .catch(() => {})
359}
360
361let shutdownInProgress = false
362let failsafeTimer: ReturnType<typeof setTimeout> | undefined

Callers 15

showSetupScreensFunction · 0.85
mainFunction · 0.85
runFunction · 0.85
_temp2Function · 0.85
DevChannelsDialogFunction · 0.85
_tempFunction · 0.85
_tempFunction · 0.85
TrustDialogFunction · 0.85
_temp7Function · 0.85
_temp6Function · 0.85
persistToRemoteMethod · 0.85

Calls 5

gracefulShutdownFunction · 0.85
logForDebuggingFunction · 0.85
cleanupTerminalModesFunction · 0.85
printResumeHintFunction · 0.85
forceExitFunction · 0.85

Tested by

no test coverage detected