File tree Expand file tree Collapse file tree 1 file changed +17
-15
lines changed Expand file tree Collapse file tree 1 file changed +17
-15
lines changed Original file line number Diff line number Diff line change @@ -1099,25 +1099,27 @@ async function sendRequest(
10991099 await options . onBeforeRequest ( req )
11001100 }
11011101
1102- // Start stall detection after onBeforeRequest completes but before the actual network request
1103- if ( stallDetector ) {
1104- stallDetector . start ( )
1105- }
1106-
1107- try {
1108- const res = await req . send ( body )
1109-
1110- if ( typeof options . onAfterResponse === 'function' ) {
1111- await options . onAfterResponse ( req , res )
1102+ const sendWithStallDetection = async ( ) : Promise < HttpResponse > => {
1103+ if ( stallDetector ) {
1104+ stallDetector . start ( )
11121105 }
11131106
1114- return res
1115- } finally {
1116- // Always stop the stall detector when the request completes (success or failure)
1117- if ( stallDetector ) {
1118- stallDetector . stop ( )
1107+ try {
1108+ return await req . send ( body )
1109+ } finally {
1110+ if ( stallDetector ) {
1111+ stallDetector . stop ( )
1112+ }
11191113 }
11201114 }
1115+
1116+ const res = await sendWithStallDetection ( )
1117+
1118+ if ( typeof options . onAfterResponse === 'function' ) {
1119+ await options . onAfterResponse ( req , res )
1120+ }
1121+
1122+ return res
11211123}
11221124
11231125/**
You can’t perform that action at this time.
0 commit comments