mafintosh / turbo-http

Blazing fast low level http server
MIT License
1k stars 47 forks source link

Doesn't work with express #2

Open coderaiser opened 6 years ago

coderaiser commented 6 years ago

It is a very interesting idea of super fast http server :). But unfortunately it is crashes on every request on different places. I'm using node v8.9.4.

When I try to use turbo-http with express everything is crashed.

$ npm i express-generator -g
$ mkdir turbu;
$ cd turbo
$ express
  create : .
   create : ./package.json
   create : ./app.js
   create : ./public
   create : ./routes
   create : ./routes/index.js
   create : ./routes/users.js
   create : ./views
   create : ./views/index.jade
   create : ./views/layout.jade
   create : ./views/error.jade
   create : ./bin
   create : ./bin/www
   create : ./public/javascripts
   create : ./public/images
   create : ./public/stylesheets
   create : ./public/stylesheets/style.css

$ npm i @mafintosh/turbo-http

I Changed in bin/www: http -> @mafintosh/turbo-http.

And after start and making request I see:

coderaiser@cloudcmd:~/2$ node bin/www
(node:12532) Warning: N-API is an experimental feature and could change at any time.
/home/coderaiser/2/node_modules/finalhandler/index.js:130
      req.socket.destroy()
                 ^

TypeError: req.socket.destroy is not a function
    at Immediate.<anonymous> (/home/coderaiser/2/node_modules/finalhandler/index.js:130:18)
    at Immediate._onImmediate (/home/coderaiser/2/node_modules/express/lib/router/index.js:635:15)
    at runCallback (timers.js:791:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)

When I try to use turbo-http in edward error was:

/home/coderaiser/edward/node_modules/send/index.js:613
  var ranges = req.headers.range
                           ^

TypeError: Cannot read property 'range' of undefined
    at SendStream.send (/home/coderaiser/edward/node_modules/send/index.js:613:28)
    at /home/coderaiser/edward/node_modules/send/index.js:775:12
    at FSReqWrap.oncomplete (fs.js:153:5)

When I try to use it with cloudcmd I got:

coderaiser@cloudcmd:~/cloudcmd$ node bin/cloudcmd.js
(node:12906) Warning: N-API is an experimental feature and could change at any time.
url: http://localhost:31337/
_stream_readable.js:718
  if (state.pipesCount === 0)
            ^

TypeError: Cannot read property 'pipesCount' of undefined
    at Request.Readable.unpipe (_stream_readable.js:718:13)
    at unpipe (/home/coderaiser/cloudcmd/node_modules/unpipe/index.js:47:12)
    at send (/home/coderaiser/cloudcmd/node_modules/finalhandler/index.js:289:3)
    at Immediate.<anonymous> (/home/coderaiser/cloudcmd/node_modules/finalhandler/index.js:135:5)
    at Immediate._onImmediate (/home/coderaiser/cloudcmd/node_modules/express/lib/router/index.js:635:15)
    at runCallback (timers.js:791:20)
    at tryOnImmediate (timers.js:751:5)
    at processImmediate [as _immediateCallback] (timers.js:722:5)

Would be great to have ability to use turbo-http with express :)

mafintosh commented 6 years ago

The API is different in places from Node.js core. It most likely will never be fully compatible for perf reasons. What should happen (ideally...) would be for new cool JSON api frameworks to be built on top :)

lukeed commented 6 years ago

I'm looking forward to trying this with Polka later today 🕺

kamilmysliwiec commented 6 years ago

@mafintosh @lukeed I'm currently testing both polka & turbo-http with Nest. Cool stuff 🙂

emkay commented 6 years ago

@coderaiser I started writing theodore which uses turbo-http and has a similar api as express. Of course it's missing a bunch of stuff, but does the basics right now.

aichholzer commented 5 years ago

@lukeed -A little late on this one but how did that testing with polka go? I gave it a run with rayo and I was able to pass some basic tests, will do some more testing in the next couple of days and report back... Curious to hear your findings though.

ohenepee commented 5 years ago

@aichholzer how did the tests go? Any numbers to show? I especially would love to see how much responses per second can be generated on a 512MB RAM 1 Core benchmark environment