File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed
testObservability/reporter Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -270,6 +270,16 @@ class MyReporter {
270270
271271 const port = process . env . REPORTER_API_PORT_NO ;
272272
273+ this . httpServer . on ( 'error' , ( error ) => {
274+ if ( error . code === 'EADDRINUSE' ) {
275+ debugOnConsole ( `Port ${ port } is already in use. HTTP server could not start.` ) ;
276+ debug ( `Port ${ port } is already in use. HTTP server could not start.` , true , error ) ;
277+ } else {
278+ debugOnConsole ( `Exception in starting reporter server : ${ error } ` ) ;
279+ debug ( `Exception in starting reporter server : ${ error } ` , true , error ) ;
280+ }
281+ } ) ;
282+
273283 this . httpServer . listen ( port , '127.0.0.1' , async ( ) => {
274284 console . log ( `Reporter HTTP server listening on port ${ port } ` ) ;
275285 } ) ;
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ const TESTHUB_CONSTANTS = require("./constants");
55const testObservabilityHelper = require ( "../../bin/testObservability/helper/helper" ) ;
66const helper = require ( "../helpers/helper" ) ;
77const accessibilityHelper = require ( "../accessibility-automation/helper" ) ;
8- const { detect } = require ( 'detect-port' ) ;
8+ const detectPort = require ( 'detect-port' ) ;
99
1010
1111const isUndefined = ( value ) => value === undefined || value === null ;
@@ -195,17 +195,18 @@ exports.logBuildError = (error, product = "") => {
195195 }
196196} ;
197197
198- exports . findAvailablePort = async ( preferredPort , maxAttempts = 10 ) => {
198+ exports . findAvailablePort = async ( preferredPort , maxAttempts = 10 ) => {
199+ const findPort = detectPort . detect || detectPort ;
199200 let port = preferredPort ;
200201 for ( let attempts = 0 ; attempts < maxAttempts ; attempts ++ ) {
201202 try {
202- const availablePort = await detect ( port ) ;
203+ const availablePort = await findPort ( port ) ;
203204
204205 if ( availablePort === port ) {
205206 return port ;
206207 } else {
207208 // Double-check suggested port
208- const verify = await detect ( availablePort ) ;
209+ const verify = await findPort ( availablePort ) ;
209210 if ( verify === availablePort ) {
210211 return availablePort ;
211212 }
You can’t perform that action at this time.
0 commit comments