1

I'm trying to do something bigpipe with koajs.

app.use(function* () {
    this.type = 'html';
    this.body = myPage.stream() // returns a readable
})

inside the myPage

myPage.prototype.stream = function() {
    var readable = new stream.Readable();
    readable._read = function() {};
    co(myRender(readable.push.bind(readable))).catch(errorHandler)
    return readable;
});

Then the render will do the rendering stuff (async);

However, it works smoothly until I tried to open multi tabs on my browser.

It will not render other pages until one is done (i had a setTimeout to simulate async stuff in the rendere).

Is there anyway to stream multiple connections simultaneously? Like it does with normal requests (not bigpipe) ?

Qiaosen Huang
  • 1,093
  • 1
  • 10
  • 25
  • I can't help you much, but definitely you should add context to your code, since koa uses `ctx` for every request, and that way every request would create a different stream – Félix Sanz Mar 18 '16 at 15:42

0 Answers0