Skip to content

Commit

Permalink
fix: safari can not in (#1590)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamjoel authored Nov 21, 2023
1 parent 778cfb3 commit d6a6697
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 32 deletions.
4 changes: 1 addition & 3 deletions web/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
declare module 'lamejs';
declare module 'react-18-input-autosize';
declare module 'fetch-readablestream' {
export default function fetchReadableStream(url: string, options?: RequestInit): Promise<Response>
}

1 change: 0 additions & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"echarts": "^5.4.1",
"echarts-for-react": "^3.0.2",
"emoji-mart": "^5.5.2",
"fetch-readablestream": "^0.2.0",
"i18next": "^22.4.13",
"i18next-resources-to-backend": "^1.1.3",
"immer": "^9.0.19",
Expand Down
8 changes: 1 addition & 7 deletions web/service/base.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import fetchStream from 'fetch-readablestream'
import { API_PREFIX, IS_CE_EDITION, PUBLIC_API_PREFIX } from '@/config'
import Toast from '@/app/components/base/toast'
import type { MessageEnd, MessageReplace, ThoughtItem } from '@/app/components/app/chat/type'
import { isSupportNativeFetchStream } from '@/utils/stream'

const TIME_OUT = 100000
const supportNativeFetchStream = isSupportNativeFetchStream()

const ContentType = {
json: 'application/json',
Expand Down Expand Up @@ -223,9 +220,6 @@ const baseFetch = <T>(
if (body && bodyStringify)
options.body = JSON.stringify(body)

// for those do not support native fetch stream, we use fetch-readablestream as polyfill
const doFetch = supportNativeFetchStream ? globalThis.fetch : fetchStream

// Handle timeout
return Promise.race([
new Promise((resolve, reject) => {
Expand All @@ -234,7 +228,7 @@ const baseFetch = <T>(
}, TIME_OUT)
}),
new Promise((resolve, reject) => {
doFetch(urlWithPrefix, options as RequestInit)
globalThis.fetch(urlWithPrefix, options as RequestInit)
.then((res) => {
const resClone = res.clone()
// Error handler
Expand Down
21 changes: 0 additions & 21 deletions web/utils/stream.ts

This file was deleted.

0 comments on commit d6a6697

Please sign in to comment.