chore: generate
This commit is contained in:
@@ -162,7 +162,11 @@ export function createWebSocketFetch(options?: CreateWebSocketFetchOptions) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
entry.fallback = true
|
entry.fallback = true
|
||||||
log.warn("websocket setup failed", { key, error: error instanceof Error ? error.message : String(error), fallback: "http" })
|
log.warn("websocket setup failed", {
|
||||||
|
key,
|
||||||
|
error: error instanceof Error ? error.message : String(error),
|
||||||
|
fallback: "http",
|
||||||
|
})
|
||||||
invalidate(entry)
|
invalidate(entry)
|
||||||
return httpFetch(input, httpInit)
|
return httpFetch(input, httpInit)
|
||||||
}
|
}
|
||||||
@@ -202,7 +206,11 @@ async function socket(
|
|||||||
maxConnectionAge: number,
|
maxConnectionAge: number,
|
||||||
signal?: AbortSignal | null,
|
signal?: AbortSignal | null,
|
||||||
) {
|
) {
|
||||||
if (entry.socket?.readyState === WebSocket.OPEN && entry.connectedAt && Date.now() - entry.connectedAt < maxConnectionAge) {
|
if (
|
||||||
|
entry.socket?.readyState === WebSocket.OPEN &&
|
||||||
|
entry.connectedAt &&
|
||||||
|
Date.now() - entry.connectedAt < maxConnectionAge
|
||||||
|
) {
|
||||||
return entry.socket
|
return entry.socket
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -201,7 +201,14 @@ export function streamResponsesWebSocket(options: StreamResponsesWebSocketOption
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!emitted) options.onFirstEvent?.()
|
if (!emitted) options.onFirstEvent?.()
|
||||||
controller?.enqueue(encoder.encode(`${text.split(/\r?\n/).map((line) => `data: ${line}`).join("\n")}\n\n`))
|
controller?.enqueue(
|
||||||
|
encoder.encode(
|
||||||
|
`${text
|
||||||
|
.split(/\r?\n/)
|
||||||
|
.map((line) => `data: ${line}`)
|
||||||
|
.join("\n")}\n\n`,
|
||||||
|
),
|
||||||
|
)
|
||||||
emitted = true
|
emitted = true
|
||||||
resetIdleTimeout("idle timeout waiting for websocket")
|
resetIdleTimeout("idle timeout waiting for websocket")
|
||||||
|
|
||||||
|
|||||||
@@ -551,7 +551,10 @@ function streamRequest(headers?: Record<string, string>, signal?: AbortSignal):
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mockFetch(
|
function mockFetch(
|
||||||
fn: (input: Parameters<typeof globalThis.fetch>[0], init: Parameters<typeof globalThis.fetch>[1]) => ReturnType<typeof globalThis.fetch>,
|
fn: (
|
||||||
|
input: Parameters<typeof globalThis.fetch>[0],
|
||||||
|
init: Parameters<typeof globalThis.fetch>[1],
|
||||||
|
) => ReturnType<typeof globalThis.fetch>,
|
||||||
): typeof globalThis.fetch {
|
): typeof globalThis.fetch {
|
||||||
return Object.assign(fn, { preconnect: globalThis.fetch.preconnect })
|
return Object.assign(fn, { preconnect: globalThis.fetch.preconnect })
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user