MCPcopy
hub / github.com/claude-code-best/claude-code / stopUdsMessaging

Function stopUdsMessaging

src/utils/udsMessaging.ts:668–704  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

666 * Stop the UDS messaging server and clean up the socket file.
667 */
668export async function stopUdsMessaging(): Promise<void> {
669 defaultSocketPath = null
670 if (!server) return
671
672 // Close all connected clients
673 for (const socket of clients) {
674 socket.destroy()
675 }
676 clients.clear()
677
678 await new Promise<void>(resolve => {
679 server!.close(() => resolve())
680 })
681 server = null
682 inbox.length = 0
683 inboxBytes = 0
684 onEnqueueCb = null
685
686 // Remove socket file (skip on Windows — pipe paths aren't files)
687 if (socketPath) {
688 await removeSocketPath(socketPath)
689 delete process.env.CLAUDE_CODE_MESSAGING_SOCKET
690 logForDebugging(
691 `[udsMessaging] server stopped, socket removed: ${socketPath}`,
692 )
693 socketPath = null
694 authToken = null
695 }
696 if (capabilityFilePath) {
697 try {
698 await unlink(capabilityFilePath)
699 } catch {
700 // Already gone
701 }
702 capabilityFilePath = null
703 }
704}
705
706/**
707 * Send a UDS message to a specific socket path (outbound — used when this

Callers 2

startUdsMessagingFunction · 0.85

Calls 7

removeSocketPathFunction · 0.85
unlinkFunction · 0.85
resolveFunction · 0.70
logForDebuggingFunction · 0.70
closeMethod · 0.65
destroyMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected