Help Needed with Type Mismatch in Stream Wrapper for Readable Streams

Can anyone help me solve this little bug, and point out any silly things I'm doing here? Just trying to make a stream wrapper for readable streams. I assume that returning the function passed to Stream.async ends the stream. Not sure though?

const readableStream = <T extends Uint8Array>(reader: ReadableStreamDefaultReader<T>) => {
    return Stream.async((emit) => { /* <--- Type 'Effect<Uint8Array, string | UnknownException, never>' is not assignable to type 'Effect<void, never, never>'. 
      Type 'Uint8Array' is not assignable to type 'void'.*/
        const generator = Effect.fn("effectReadableStreamGenerator")(function* () {
            let received = 0
            const chunks: Uint8Array[] = []
            while (true) {
                const { done, value } = yield* Effect.tryPromise(() => reader.read())
                if (!value) return yield* Effect.fail("something went wrong")
                received += value.length
                chunks.push(value)
                if (done) {
                    const blob = new Uint8Array(
                        chunks.reduce((acc, chunk) => acc + chunk.length, 0),
                    )
                    chunks.forEach((chunk, i) => blob.set(chunk, i))
                    return yield* Effect.succeed(blob)
                } else {
                    emit(Effect.succeed(Chunk.of({ received })))
                }
            }
            return yield* Effect.never
        })()
        return generator
    })
}
Was this page helpful?