fix(fs): convert async iterator syntax to manual read (#2550)

This commit is contained in:
Tim Ramage
2025-03-21 07:19:50 +00:00
committed by GitHub
parent a9cbefc910
commit 831c35ff39
3 changed files with 18 additions and 4 deletions
+6
View File
@@ -0,0 +1,6 @@
---
"fs": "patch:bug"
"fs-js": "patch:bug"
---
Fix `writeFile` ReadableStream handling due to missing async iterator support on macOS platform
File diff suppressed because one or more lines are too long
+11 -3
View File
@@ -1075,10 +1075,18 @@ async function writeFile(
if (data instanceof ReadableStream) {
const file = await open(path, options)
for await (const chunk of data) {
await file.write(chunk)
const reader = data.getReader()
try {
while (true) {
const { done, value } = await reader.read()
if (done) break
await file.write(value)
}
} finally {
reader.releaseLock()
await file.close()
}
await file.close()
} else {
await invoke('plugin:fs|write_file', data, {
headers: {