(response: DebugProtocol.DisconnectResponse, args: DebugProtocol.DisconnectArguments)
| 1416 | |
| 1417 | protected disconnectingPromise: Promise<void> = undefined; |
| 1418 | protected async disconnectRequest(response: DebugProtocol.DisconnectResponse, args: DebugProtocol.DisconnectArguments): Promise<void> { |
| 1419 | TcpPortScanner.PortAllocated.removeListener('allocated', this.tcpPortAllocatedListner); |
| 1420 | if (this.disconnectingPromise) { |
| 1421 | // One of the ways this happens when we have the following |
| 1422 | // * we are a child session of someone else |
| 1423 | // * the parent has already asked us to quit and in the process, we sent a TerminatedEvent to VSCode |
| 1424 | // * VSCode in turn asks to disconnect. all is good, we were quitting anyways. Not sure exactly what else we could do |
| 1425 | this.serverConsoleLog('Got disconnect request while we are already disconnecting'); |
| 1426 | await this.disconnectingPromise; |
| 1427 | this.sendResponse(response); |
| 1428 | return Promise.resolve(); |
| 1429 | } else { |
| 1430 | // We have a problem here. It is not clear in the case of managed life-cycles what the children are supposed to do. |
| 1431 | // If we try to wait for children to exit cleanly and then exit ourselves, we are having issues (when not in server mode |
| 1432 | // which is always the case for production). |
| 1433 | // |
| 1434 | // If we wait for a timeout or event and the child exits in the meantime, VSCode is killing the parent while we are still |
| 1435 | // not yet done terminating ourselves. So, let the children terminate and in the meantime, at the same time we terminate ourselves |
| 1436 | // What really happens is that when/if we terminate first, the server (if any) is killed and the children will automatically die |
| 1437 | // but not gracefully. |
| 1438 | // |
| 1439 | // We have a catchall exit handler defined in server.ts but hopefully, we can get rid of that |
| 1440 | // |
| 1441 | // Maybe longer term, what might be better is that we enter server mode ourselves. For another day |
| 1442 | if (this.args.chainedConfigurations?.enabled) { |
| 1443 | this.serverConsoleLog('Begin disconnectRequest children'); |
| 1444 | this.sendEvent(new GenericCustomEvent('session-terminating', args)); |
| 1445 | } |
| 1446 | return this.disconnectRequest2(response, args); |
| 1447 | } |
| 1448 | } |
| 1449 | |
| 1450 | protected async tryDeleteBreakpoints(): Promise<boolean> { |
| 1451 | try { |
nothing calls this directly
no test coverage detected