vercel / micro

Asynchronous HTTP microservices
MIT License
10.59k stars 459 forks source link

Micro doesn't respond in programmatic use #403

Closed aredridel closed 5 years ago

aredridel commented 5 years ago

I've got a basic server:

const http = require('http')
const micro = require('micro')

const server = new http.Server(micro(async (req, res) => {
  return 'Hello world'
}))

server.listen(5000)

It doesn't actually respond on port 5000 (request never completes).

Removing micro from the equation and using this code:

const http = require('http')
const micro = require('micro')

const server = new http.Server(async (req, res) => {
  res.end('Hello world')
}))

server.listen(5000)

works

This is using node 12.3.1 & micro 9.3.4

timneutkens commented 5 years ago

Looks like you're using the programmatic usage for the new version of micro which is currently available as micro@canary. For the latest branch docs you can visit npm: https://npmjs.com/micro 🙏

paulmillr commented 5 years ago

@timneutkens why don't you mention this in README? It's been like 3 months.

morgs32 commented 5 years ago

🤕 🔫

morgs32 commented 5 years ago

image

How many people have to suffer! (said with jest, but after losing 30 min)

Pull request here: https://github.com/zeit/micro/pull/416