fix(SmartDuplex): Fix issue with SmartDuplex fromWebReadableStream method

This commit is contained in:
2024-10-16 02:02:48 +02:00
parent 60c8824f33
commit f211cc8ddd
4 changed files with 15 additions and 15 deletions

View File

@@ -58,19 +58,13 @@ export class SmartDuplex<TInput = any, TOutput = any> extends Duplex {
const smartDuplex = new SmartDuplex<T, T>({
readFunction: async () => {
const reader = readableStream.getReader();
try {
while (true) {
const { value, done } = await reader.read();
if (value !== undefined) {
smartDuplex.push(value);
}
if (done) {
smartDuplex.end();
break;
}
}
} finally {
reader.releaseLock();
const { value, done } = await reader.read();
if (value !== undefined) {
smartDuplex.push(value);
}
reader.releaseLock();
if (done) {
smartDuplex.end();
}
},
});