Skip to content

Commit 07e6f9c

Browse files
committed
Support terminateThreads.
1 parent d8921aa commit 07e6f9c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/phpDebug.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ class PhpDebugSession extends vscode.DebugSession {
179179
default: true,
180180
},
181181
],
182+
supportsTerminateThreadsRequest: true,
182183
}
183184
this.sendResponse(response)
184185
}
@@ -982,6 +983,34 @@ class PhpDebugSession extends vscode.DebugSession {
982983
this.sendErrorResponse(response, new Error('Pausing the execution is not supported by XDebug'))
983984
}
984985

986+
protected async terminateThreadsRequest(
987+
response: VSCodeDebugProtocol.TerminateThreadsResponse,
988+
args: VSCodeDebugProtocol.TerminateThreadsArguments
989+
) {
990+
try {
991+
if (args.threadIds) {
992+
await Promise.all(
993+
args.threadIds.map(async threadId => {
994+
const connection = this._connections.get(threadId)
995+
if (connection) {
996+
await Promise.race([
997+
connection.sendStopCommand(),
998+
new Promise(resolve => setTimeout(resolve, 500)),
999+
])
1000+
await connection.close()
1001+
this._connections.delete(threadId)
1002+
this._waitingConnections.delete(connection)
1003+
}
1004+
})
1005+
)
1006+
}
1007+
this.sendResponse(response)
1008+
} catch (error) {
1009+
this.sendErrorResponse(response, error)
1010+
return
1011+
}
1012+
}
1013+
9851014
protected async disconnectRequest(
9861015
response: VSCodeDebugProtocol.DisconnectResponse,
9871016
args: VSCodeDebugProtocol.DisconnectArguments

0 commit comments

Comments
 (0)