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

Method forceStop

nodejs/src/client.ts:1051–1108  ·  view source on GitHub ↗

* Forcefully stops the CLI server without graceful cleanup. * * Use this when stop fails or takes too long. This method: * - Clears all sessions immediately without destroying them * - Force closes the connection * - Sends SIGKILL to the CLI process (if spawned by th

()

Source from the content-addressed store, hash-verified

1049 * ```
1050 */
1051 async forceStop(): Promise<void> {
1052 this.forceStopping = true;
1053
1054 // Clear sessions immediately without trying to destroy them
1055 for (const session of this.sessions.values()) {
1056 session._markDisconnected();
1057 }
1058 this.sessions.clear();
1059
1060 // Force close connection. Suppress writer failures first so teardown
1061 // write rejections don't surface as unhandled rejections.
1062 if (this.messageWriter) {
1063 this.messageWriter.suppressWriteErrors = true;
1064 }
1065 if (this.connection) {
1066 try {
1067 this.connection.dispose();
1068 } catch {
1069 // Ignore errors during force stop
1070 }
1071 this.connection = null;
1072 this.messageWriter = null;
1073 this._rpc = null;
1074 this._internalRpc = null;
1075 }
1076
1077 // Clear models cache
1078 this.modelsCache = null;
1079
1080 if (this.socket) {
1081 try {
1082 this.socket.destroy(); // destroy() is more forceful than end()
1083 } catch {
1084 // Ignore errors
1085 }
1086 this.socket = null;
1087 }
1088
1089 // Force kill CLI process (only if we spawned it)
1090 if (this.cliProcess && !this.isExternalServer) {
1091 try {
1092 this.cliProcess.kill("SIGKILL");
1093 } catch {
1094 // Ignore errors
1095 }
1096 this.cliProcess = null;
1097 }
1098
1099 if (this.cliStartTimeout) {
1100 clearTimeout(this.cliStartTimeout);
1101 this.cliStartTimeout = null;
1102 }
1103
1104 this.state = "disconnected";
1105 this.runtimePort = null;
1106 this.stderrBuffer = "";
1107 this.processExitPromise = null;
1108 }

Callers 15

setupClientFunction · 0.95
createClientWithEnvFunction · 0.95
createMcpAppsClientFunction · 0.95
createTcpServerFunction · 0.95
createConnectingClientFunction · 0.95
startEphemeralClientFunction · 0.95
toolSet.test.tsFile · 0.45
client.test.tsFile · 0.45
disposeIsolatedFunction · 0.45
forceStopFunction · 0.45

Calls 3

_markDisconnectedMethod · 0.80
clearMethod · 0.45
killMethod · 0.45

Tested by 13

setupClientFunction · 0.76
createClientWithEnvFunction · 0.76
createMcpAppsClientFunction · 0.76
createTcpServerFunction · 0.76
createConnectingClientFunction · 0.76
startEphemeralClientFunction · 0.76
disposeIsolatedFunction · 0.36
forceStopFunction · 0.36
disposeIsolatedFunction · 0.36
onTestFinishedForceStopFunction · 0.36
onTestFinishedForceStopFunction · 0.36
forceStopFunction · 0.36