MCPcopy Create free account
hub / github.com/TanStack/router / runSequentialRequestLoop

Function runSequentialRequestLoop

benchmarks/memory/server/bench-utils.ts:81–120  ·  view source on GitHub ↗
(
  handler: StartRequestHandler,
  options: RunSequentialRequestLoopOptions,
)

Source from the content-addressed store, hash-verified

79}
80
81export async function runSequentialRequestLoop(
82 handler: StartRequestHandler,
83 options: RunSequentialRequestLoopOptions,
84) {
85 const {
86 iterations = 10,
87 buildRequest,
88 validateResponse,
89 pinGcBetweenIterations = false,
90 verifyGcFloor = false,
91 } = options
92 const random =
93 options.seed !== undefined
94 ? createDeterministicRandom(options.seed)
95 : options.random
96 const validate =
97 validateResponse ??
98 ((response: Response, request: Request) => {
99 if (response.status !== 200) {
100 throw new Error(
101 `Request failed with non-200 status ${response.status} (${request.url})`,
102 )
103 }
104 })
105
106 const gcPinState = verifyGcFloor ? createGcPinState() : undefined
107
108 for (let index = 0; index < iterations; index++) {
109 const request = buildRequest(random, index)
110 const response = await handler.fetch(request)
111
112 validate(response, request)
113
114 await drainResponse(response)
115
116 if (pinGcBetweenIterations) {
117 await settleAndPinGc(gcPinState)
118 }
119 }
120}
121
122// Renderer/stream teardown spans several event-loop turns (React and Vue
123// need more than the two turns the original barrier allowed for), and a

Callers 9

runFunction · 0.90
runFunction · 0.90
runFunction · 0.90
runRedirectFunction · 0.90
runNotFoundFunction · 0.90
runErrorFunction · 0.90
runUnmatchedFunction · 0.90
runFunction · 0.90
runFunction · 0.90

Calls 6

createGcPinStateFunction · 0.85
settleAndPinGcFunction · 0.85
drainResponseFunction · 0.70
fetchMethod · 0.65
validateFunction · 0.50

Tested by

no test coverage detected