fix(httpapi): expose v2 catalog errors (#28498)
This commit is contained in:
@@ -98,12 +98,14 @@ function assistant(id: string) {
|
||||
} satisfies SdkEvent
|
||||
}
|
||||
|
||||
function feed<T>() {
|
||||
const StreamClosed = undefined as never
|
||||
|
||||
function feed<T, R = never>(returnValue: R = StreamClosed) {
|
||||
const list: T[] = []
|
||||
let done = false
|
||||
let wake: (() => void) | undefined
|
||||
|
||||
const wrapped = (async function* () {
|
||||
const wrapped = (async function* (): AsyncGenerator<T, R, unknown> {
|
||||
while (!done || list.length > 0) {
|
||||
if (list.length === 0) {
|
||||
await new Promise<void>((resolve) => {
|
||||
@@ -119,6 +121,7 @@ function feed<T>() {
|
||||
|
||||
yield next
|
||||
}
|
||||
return returnValue as R
|
||||
})()
|
||||
|
||||
return {
|
||||
@@ -166,10 +169,11 @@ function globalSse(stream: GlobalEventStream) {
|
||||
}
|
||||
|
||||
function wrapGlobalStream(stream: EventStream): GlobalEventStream {
|
||||
return (async function* () {
|
||||
return (async function* (): GlobalEventStream {
|
||||
for await (const event of stream) {
|
||||
yield globalEvent(event)
|
||||
}
|
||||
return StreamClosed
|
||||
})()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user