juliangruber / juliangruber/koa-write
hangs for me
- Dominant language
- JavaScript
- Stars
- 6
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
My code is something like this:
```
function *(next) {
yield next;
this.type = 'text/event-stream; charset=utf-8';
this.set('Cache-Control', 'no-cache');
this.set('Connection', 'keep-alive');
this.body = PassThrough();
let generator = foo();
let result = generator.next();
while (1) {
if (result.done) break;
if (result.value instanceof Promise) {
result = generator.next(yield result.value);
} else {
yield write(this, 'data: '+JSON.stringify(result.value)+'\n\n');
result = generator.next();
}
}
yield write(this, 'event: done\ndata: \n\n');
return this.body.end();
}
```
The generator returns 1 promise, then 10 non-promises, then 1 promise, then 10 non-promises, et cetera. Each promise takes a few hundred milliseconds to resolve.
It works great with 1 or 2 promises, but when I have 3 promises, it hangs on the 28th call to write().
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.