MCPcopy Index your code
hub / github.com/github/copilot-sdk / Disconnect

Method Disconnect

go/session.go:1656–1686  ·  view source on GitHub ↗

Disconnect closes this session and releases all in-memory resources (event handlers, tool handlers, permission handlers). The caller should ensure the session is idle (e.g., [Session.SendAndWait] has returned) before disconnecting. If the session is not idle, in-flight event handlers or tool handle

()

Source from the content-addressed store, hash-verified

1654// log.Printf("Failed to disconnect session: %v", err)
1655// }
1656func (s *Session) Disconnect() error {
1657 _, err := s.client.Request(context.Background(), "session.destroy", sessionDestroyRequest{SessionID: s.SessionID})
1658 if err != nil {
1659 return fmt.Errorf("failed to disconnect session: %w", err)
1660 }
1661
1662 s.closeOnce.Do(func() { close(s.eventCh) })
1663
1664 // Clear handlers
1665 s.handlerMutex.Lock()
1666 s.handlers = nil
1667 s.handlerMutex.Unlock()
1668
1669 s.toolHandlersM.Lock()
1670 s.toolHandlers = nil
1671 s.toolHandlersM.Unlock()
1672
1673 s.permissionMux.Lock()
1674 s.permissionHandler = nil
1675 s.permissionMux.Unlock()
1676
1677 s.commandHandlersMu.Lock()
1678 s.commandHandlers = nil
1679 s.commandHandlersMu.Unlock()
1680
1681 s.elicitationMu.Lock()
1682 s.elicitationHandler = nil
1683 s.elicitationMu.Unlock()
1684
1685 return nil
1686}
1687
1688// Abort aborts the currently processing message in this session.
1689//

Callers 15

StopMethod · 0.80
mainFunction · 0.80
TestAbortE2EFunction · 0.80
TestProviderEndpointE2EFunction · 0.80
TestSuspendE2EFunction · 0.80
TestPendingWorkResumeE2EFunction · 0.80
startTCPServerFunction · 0.80
TestRPCScheduleE2EFunction · 0.80
TestSessionFSE2EFunction · 0.80

Calls 2

closeFunction · 0.50
RequestMethod · 0.45

Tested by 15

TestAbortE2EFunction · 0.64
TestProviderEndpointE2EFunction · 0.64
TestSuspendE2EFunction · 0.64
TestPendingWorkResumeE2EFunction · 0.64
startTCPServerFunction · 0.64
TestRPCScheduleE2EFunction · 0.64
TestSessionFSE2EFunction · 0.64
TestMultiTurnE2EFunction · 0.64
TestPermissionsE2EFunction · 0.64
TestCommandsE2EFunction · 0.64