@@ -13,14 +13,15 @@ import { ChildProcess } from 'child_process';
1313import { CliExitData } from '../cli' ;
1414import { isURL } from 'validator' ;
1515import { Refs , Ref , Type } from '../util/refs' ;
16- import { Delayer , wait } from '../util/async' ;
16+ import { Delayer } from '../util/async' ;
1717import { Platform } from '../util/platform' ;
1818import path = require( 'path' ) ;
1919import globby = require( 'globby' ) ;
2020import { selectWorkspaceFolder } from '../util/workspace' ;
2121import { exec } from 'child_process' ;
2222import { ToolsConfig } from '../tools' ;
2323const waitPort = require ( 'wait-port' ) ;
24+ const getPort = require ( 'get-port' ) ;
2425
2526export class Component extends OpenShiftItem {
2627 public static extensionContext : ExtensionContext ;
@@ -595,12 +596,12 @@ export class Component extends OpenShiftItem {
595596 }
596597
597598 static async startOdoAndConnectDebugger ( toolLocation : string , component : OpenShiftObject , config : DebugConfiguration ) {
598- const cp = exec ( `"${ toolLocation } " debug port-forward` , { cwd : component . contextPath . fsPath } ) ;
599+ const port = await getPort ( ) ;
600+ const cp = exec ( `"${ toolLocation } " debug port-forward --local-port ${ port } ` , { cwd : component . contextPath . fsPath } ) ;
599601 return new Promise < String > ( ( resolve , reject ) => {
600602 cp . stdout . on ( 'data' , async ( data : string ) => {
601603 const port = data . trim ( ) . match ( / (?< localPort > \d + ) \: \d + $ / ) ;
602- if ( port . groups . localPort ) {
603- await wait ( 1000 ) ;
604+ if ( port ?. groups ?. localPort ) {
604605 await waitPort ( {
605606 host : 'localhost' ,
606607 port : parseInt ( port . groups . localPort )
0 commit comments