From e8e72244815b206742f02ae31cc65e8d888115c4 Mon Sep 17 00:00:00 2001 From: David <2889367+daveleroy@users.noreply.github.com> Date: Fri, 14 Oct 2022 23:33:16 -0700 Subject: [PATCH] js: use SocketTransport.connect_with_process --- modules/adapters/js.py | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/modules/adapters/js.py b/modules/adapters/js.py index cd89abb..11bae4e 100644 --- a/modules/adapters/js.py +++ b/modules/adapters/js.py @@ -50,41 +50,16 @@ async def start(self, log: core.Logger, configuration: dap.ConfigurationExpanded node = await util.get_and_warn_require_node(self.type, log) install_path = util.vscode.install_path('js') + + port = util.get_open_port() + command = [ node, - f'{install_path}/extension/src/vsDebugServer.bundle.js' + f'{install_path}/extension/src/vsDebugServer.bundle.js', + f'{port}', ] - process = dap.Process(command, None) - - try: - try: - line = (await process.readline(process.stdout)).decode('utf-8') - # result = re.match(r'Debug server listening at (.*)', line) - result = re.match(r'(.*)', line) - if not result: - raise core.Error(f'Unable to parse debug server port from line: {line}') - - port = int(result.group(1)) - return Transport(log, process, port) - - except EOFError: - ... - - # read out stderr there might be something interesting here - try: - while True: - line = await process.readline(process.stderr) - log.error(line.decode('utf-8')) - - except EOFError: - ... - - raise core.Error("Unable to find debug server port") - - except: - process.dispose() - raise + return await dap.SocketTransport.connect_with_process(log, command, port) async def on_custom_request(self, session: dap.Session, request: str, arguments: Any) -> Any: if request == 'attachedChildSession':