mirror of
https://github.com/anomalyco/opencode.git
synced 2026-06-01 06:11:30 +00:00
chore: generate
This commit is contained in:
parent
62da1e7682
commit
2f1547ebaf
3 changed files with 22 additions and 4 deletions
|
|
@ -162,7 +162,11 @@ export function createWebSocketFetch(options?: CreateWebSocketFetchOptions) {
|
|||
}
|
||||
|
||||
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)
|
||||
return httpFetch(input, httpInit)
|
||||
}
|
||||
|
|
@ -202,7 +206,11 @@ async function socket(
|
|||
maxConnectionAge: number,
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,14 @@ export function streamResponsesWebSocket(options: StreamResponsesWebSocketOption
|
|||
}
|
||||
|
||||
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
|
||||
resetIdleTimeout("idle timeout waiting for websocket")
|
||||
|
||||
|
|
|
|||
|
|
@ -551,7 +551,10 @@ function streamRequest(headers?: Record<string, string>, signal?: AbortSignal):
|
|||
}
|
||||
|
||||
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 {
|
||||
return Object.assign(fn, { preconnect: globalThis.fetch.preconnect })
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue