molnarg / node-http2

An HTTP/2 client and server implementation for node.js
MIT License
1.79k stars 185 forks source link

Can't manage to push multiple requests #164

Closed akc42 closed 8 years ago

akc42 commented 8 years ago

I have tried a variety of ways to send a list of 21 files in a push request. But it seems that somewhere something is ending causing the server to crash

/home/alan/dev/node-http2/lib/protocol/stream.js:627
      throw new Error('Sending illegal frame (' + frame.type + ') in ' + this.state + ' state.');
      ^

Error: Sending illegal frame (DATA) in CLOSED state.
    at Stream.transition [as _transition] (/home/alan/dev/node-http2/lib/protocol/stream.js:627:13)
    at Stream._pushUpstream (/home/alan/dev/node-http2/lib/protocol/stream.js:230:8)
    at Stream._finishing (/home/alan/dev/node-http2/lib/protocol/stream.js:351:10)
    at emitNone (events.js:67:13)
    at Stream.emit (events.js:166:7)
    at finishMaybe (_stream_writable.js:468:14)
    at endWritable (_stream_writable.js:478:3)
    at Stream.Writable.end (_stream_writable.js:443:5)
    at OutgoingResponse._finish (/home/alan/dev/node-http2/lib/http.js:355:17)
    at emitNone (events.js:72:20)

I go through a process which gives me an array of objects with the push url and filename in each object. My code is

        if(req.url === '/' || req.url === '/index.html') {
          if(res.push) {
            pushlist.forEach(item=> {
              var p = res.push(item.url)
              p.writeHead(200);
              fs.createReadStream(item.filename).pipe(p);
            })
          }
        }
        router(req,res,donewrapper);

the router(req,res,donewrapper); goes on to server index.html via serve-static.

without the push stuff, the server works perfectly - and single stepping through the initialisation of each of the file readstreams also seems to work. It is only later when one of the streams end (see how OutgoingResponse._finish is at the bottom of the call stack) that this happens.

I don't know where to go next.

nwgh commented 8 years ago

This looks like a duplicate of #107 (the stack is exactly the same). I suspect your client is sending a RST_STREAM for one or more of the pushes, for some reason or another.