-
Notifications
You must be signed in to change notification settings - Fork 179
fix: fix bug with polyfill fetch #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@microsoft-github-policy-service agree
When using fetch-event-source in the webview of iOS or Android, it is important to note that the fetch method is not implemented as native code. Instead, it is a polyfill that provides functionality similar to the native fetch method. One specific difference is that the polyfill does not have a response with a body of type ReadableStream
. Considering this limitation is therefore crucial in such cases.
congjinruo
commented
Aug 1, 2024
your code may cause repeated fetch requests. I adjusted it.
export async function getBytes(response: Response, onChunk: (arr: Uint8Array) => void) { const reader = response.body?.getReader(); if (reader) { let result; while (!(result = await reader.read()).done) { onChunk(result.value); } } else { onChunk(new Uint8Array(await response.arrayBuffer())); } }
No description provided.