@@ -139,7 +139,7 @@ if (!amMainInstance) {
139
139
app . quit ( ) ;
140
140
} else {
141
141
const logStream = createWriteStream ( LAST_RUN_LOG_PATH ) ;
142
- logStream . write ( `--- Launching HTTP Toolkit desktop v${ DESKTOP_VERSION } ---\n` ) ;
142
+ logStream . write ( `--- Launching HTTP Toolkit desktop v${ DESKTOP_VERSION } at ${ new Date ( ) . toISOString ( ) } ---\n` ) ;
143
143
144
144
const args = yargs
145
145
. option ( 'with-forwarding' , {
@@ -361,6 +361,8 @@ if (!amMainInstance) {
361
361
console . log ( 'All server versions installed are outdated, deleting' ) ;
362
362
await rmRF ( serverUpdatesPath ) ;
363
363
}
364
+
365
+ logStream . write ( 'Server cleanup check completed\n' ) ;
364
366
}
365
367
366
368
// When run *before* the server starts, this allows us to check whether the port is already in use,
@@ -381,11 +383,13 @@ if (!amMainInstance) {
381
383
delay ( 100 )
382
384
] )
383
385
. finally ( ( ) => {
386
+ logStream . write ( 'Port check completed\n' ) ;
384
387
conn . destroy ( ) ;
385
388
} ) ;
386
389
}
387
390
388
391
async function startServer ( retries = 2 ) {
392
+ logStream . write ( 'Starting server\n' ) ;
389
393
const binName = isWindows ? 'httptoolkit-server.cmd' : 'httptoolkit-server' ;
390
394
const serverBinPath = path . join ( RESOURCES_PATH , 'httptoolkit-server' , 'bin' , binName ) ;
391
395
const serverBinCommand = isWindows ? `"${ serverBinPath } "` : serverBinPath ;
@@ -423,7 +427,15 @@ if (!amMainInstance) {
423
427
serverStdout . pipe ( logStream ) ;
424
428
serverStderr . pipe ( logStream ) ;
425
429
430
+ const startTime = Date . now ( ) ;
431
+ let seenOutput = false ;
426
432
server . stdout ! . on ( 'data' , ( data ) => {
433
+ // Server always produces output immediately, which works nicely to detect actual start time (and
434
+ // any issues due to AV scans or similar).
435
+ if ( ! seenOutput ) {
436
+ seenOutput = true ;
437
+ console . log ( `Server took ${ Date . now ( ) - startTime } ms to begin startup` ) ;
438
+ }
427
439
addBreadcrumb ( { category : 'server-stdout' , message : data . toString ( 'utf8' ) , level : < any > 'info' } ) ;
428
440
} ) ;
429
441
0 commit comments