MCPcopy Create free account
hub / github.com/langgenius/dify / streamFetch

Function streamFetch

cli/src/http/client.ts:292–311  ·  view source on GitHub ↗
(path: string, callOpts?: RequestOptions)

Source from the content-addressed store, hash-verified

290 }
291
292 const streamFetch = (path: string, callOpts?: RequestOptions): Promise<Response> => {
293 // SSE bodies must not be aborted by a request-level timeout — `0` is the buildRequest
294 // sentinel for "no timeout" and also overrides the client default.
295 //
296 // A stream normally never retries (a mid-stream replay would double-send). When the caller
297 // opts into 429 retry, allow a bounded budget: the 429 admission rejection arrives as a plain
298 // body before the stream opens, and execute()'s 429 branch is the only path that fires for a
299 // POST — shouldRetry still rejects POST for transport / 5xx, so nothing else replays.
300 const retryAttempts = callOpts?.retryOnRateLimit === true
301 ? (callOpts.retryAttempts ?? RATE_LIMIT_MAX_ATTEMPTS)
302 : 0
303 const finalOpts: RequestOptions = {
304 ...callOpts,
305 method: callOpts?.method ?? 'GET',
306 retryAttempts,
307 timeoutMs: 0,
308 }
309 const built = buildRequest(state, path, finalOpts, false)
310 return execute(state, built.request, built.resolved, built.effectiveTimeoutMs, built.userSignal)
311 }
312
313 // Low-level entrypoint for oRPC's OpenAPILink: executes an already-built, absolute-URL
314 // Request through the same transport (UA+bearer hooks, retry, timeout, error-map) while

Callers

nothing calls this directly

Calls 2

buildRequestFunction · 0.85
executeFunction · 0.85

Tested by

no test coverage detected