spdy-http2 / node-spdy

SPDY server on Node.js
2.81k stars 196 forks source link

Conflict with Node new version: stream_base_commons.js:62 var err = req.handle.writev(req, chunks, allBuffers); #343

Closed bbagherian closed 5 years ago

bbagherian commented 5 years ago

I installed Nodejs on a new system with all dependencies just yesterday, so all packages are almost updated. However I get the error below with this simple code:

Node version: v10.11.0 OS: Debian 9.4 (x86-64)

Code:

'use strict';

const express = require('express');
var spdy = require('spdy'),
fs = require('fs');

const hostname = '0.0.0.0';
const port = 3030;

var options = {
  key: fs.readFileSync(__dirname + '/test.key'),
  cert: fs.readFileSync(__dirname + '/test.cert'),

  spdy: {
    protocols: [ 'h2', 'spdy/3.1', 'http/1.1' ],
    plain: false,
    'x-forwarded-for': true,

    connection: {
      windowSize: 1024 * 1024, 
      autoSpdy31: false
    }
  }
};

var server = spdy.createServer(options, function(req, res) {
  res.writeHead(200);
  res.write('a');
  res.end('hello world!');
});

server.listen(port, hostname, () => {
  console.log('Server running');
});

Error:

internal/stream_base_commons.js:62
  var err = req.handle.writev(req, chunks, allBuffers);
                       ^

TypeError: req.handle.writev is not a function
    at writevGeneric (internal/stream_base_commons.js:62:24)
    at Socket._writeGeneric (net.js:711:5)
    at Socket._writev (net.js:720:8)
    at doWrite (_stream_writable.js:408:12)
    at clearBuffer (_stream_writable.js:517:5)
    at Socket.Writable.uncork (_stream_writable.js:314:7)
    at Socket.Writable.end (_stream_writable.js:584:10)
    at Socket.end (net.js:544:31)
    at ServerResponse.end (/........./Node/node_modules/spdy/lib/spdy/response.js:77:15)
    at Server.<anonymous> (/................../Node/test.js:64:7)
coolaj86 commented 5 years ago

Fix is here: https://github.com/GrishaevPavel/spdy-transport/commit/c33ebe7fc3b46c94c5b466db421ff0036aa1847f

And here, actually: https://github.com/spdy-http2/node-spdy/pull/342

smcelhinney commented 5 years ago

This seems to happen on Node 10+ 100% of the time, and Node 10.x is now LTS as of today. Are there plans to patch to resolve?

johntran commented 5 years ago

@coolaj86 I tried applying that fix and it only works on node 10.5.0. I'm able to replicate that error on 10.13.0.

I wish I can reply back with a solution for higher versions of Node but I haven't had the time to investigate it further. I ended up downgrading back to 10.5.0 and putting this issue on the backlog to investigate later.

jacobheun commented 5 years ago

This is fixed in 4.0.0 via #351