Troubleshooting ReadableStream Issues in Next.js Route Handler

Hey folks! I'm trying to create a ReadableStream and return it from a Next.js route handler. I'm returning roughly the below. I'm currently having 2 issues with that:

1. My stream stops as soon as I return yield* the
Response
, I guess Effect cleans up the scope/fiber at that point? 🤔
2. My Stream.ensuring is never called, not even if I drain the ReadableStream by logging all the chunks

I've been bashing my head against this for a day and feel like I'm 🤏 this close, can anyone help me figure out the last bits?
CleanShot_2024-03-29_at_11.15.422x.png
Was this page helpful?