|
|
@@ -3,6 +3,7 @@ import { createParser } from 'eventsource-parser'
|
|
|
import * as types from './types'
|
|
|
import { fetch as globalFetch } from './fetch'
|
|
|
import { streamAsyncIterable } from './stream-async-iterable'
|
|
|
+import { Logger } from '@nestjs/common'
|
|
|
|
|
|
export async function fetchSSE(
|
|
|
url: string,
|
|
|
@@ -66,6 +67,7 @@ export async function fetchSSE(
|
|
|
}
|
|
|
|
|
|
if (!res.body.getReader) {
|
|
|
+ Logger.log('fetchSSE: using polyfill', 'fetchSSE')
|
|
|
// Vercel polyfills `fetch` with `node-fetch`, which doesn't conform to
|
|
|
// web standards, so this is a workaround...
|
|
|
const body: NodeJS.ReadableStream = res.body as any
|
|
|
@@ -84,6 +86,7 @@ export async function fetchSSE(
|
|
|
onMessage('[DONE]')
|
|
|
})
|
|
|
} else {
|
|
|
+ Logger.log('fetchSSE: using native', 'fetchSSE')
|
|
|
for await (const chunk of streamAsyncIterable(res.body)) {
|
|
|
const str = new TextDecoder().decode(chunk)
|
|
|
feed(str)
|