@@ -339,13 +339,7 @@ async function sendSocketRequest(
339339 handleRequestTimeout ( {
340340 info,
341341 statePaths,
342- remote : false ,
343- timeoutMs,
344- requestId : req . meta ?. requestId ,
345- command : req . command ,
346- platform : req . flags ?. platform ,
347- session : req . session ,
348- action : req . positionals ?. [ 0 ] ,
342+ ...timeoutRequestContext ( req , false , timeoutMs ) ,
349343 } ) ,
350344 ) ;
351345 } , timeoutMs )
@@ -381,6 +375,26 @@ async function sendSocketRequest(
381375 } ) ;
382376}
383377
378+ // The fields a timed-out request is described by, read once so a socket and an HTTP timeout cannot
379+ // describe the same request differently.
380+ type TimeoutRequestFields = Omit < Parameters < typeof handleRequestTimeout > [ 0 ] , 'info' | 'statePaths' > ;
381+
382+ function timeoutRequestContext (
383+ req : DaemonRequest ,
384+ remote : boolean ,
385+ timeoutMs : number ,
386+ ) : TimeoutRequestFields {
387+ return {
388+ remote,
389+ timeoutMs,
390+ requestId : req . meta ?. requestId ,
391+ command : req . command ,
392+ platform : req . flags ?. platform ,
393+ session : req . session ,
394+ action : req . positionals ?. [ 0 ] ,
395+ } ;
396+ }
397+
384398async function sendHttpRequest (
385399 info : DaemonInfo ,
386400 req : DaemonRequest ,
@@ -468,13 +482,7 @@ async function sendHttpRequest(
468482 handleRequestTimeout ( {
469483 info,
470484 statePaths,
471- remote,
472- timeoutMs,
473- requestId : req . meta ?. requestId ,
474- command : req . command ,
475- platform : req . flags ?. platform ,
476- session : req . session ,
477- action : req . positionals ?. [ 0 ] ,
485+ ...timeoutRequestContext ( req , remote , timeoutMs ) ,
478486 } ) ,
479487 ) ;
480488 } , timeoutMs )
0 commit comments