Skip to content

Commit

Permalink
js: use SocketTransport.connect_with_process
Browse files Browse the repository at this point in the history
  • Loading branch information
daveleroy committed Oct 15, 2022
1 parent 48014c8 commit e8e7224
Showing 1 changed file with 6 additions and 31 deletions.
37 changes: 6 additions & 31 deletions modules/adapters/js.py
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down

0 comments on commit e8e7224

Please sign in to comment.