Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v9.4.1 breaks in nodejs12 especially node:12-alpine #463

Closed
samarjit opened this issue Aug 2, 2022 · 8 comments
Closed

v9.4.1 breaks in nodejs12 especially node:12-alpine #463

samarjit opened this issue Aug 2, 2022 · 8 comments

Comments

@samarjit
Copy link

samarjit commented Aug 2, 2022

I am not able to pin point the problem why it breaks in node:12-alpine image. When I log into the container I do see process listening on port 3000. But curl http://localhost:3000/ishealthy gets stuck and was failing even while running inside the pod using exec. Nginx reports connection refused to this container.

/app # ps
PID   USER     TIME  COMMAND
    1 root      0:00 node /opt/yarn-v1.22.5/bin/yarn.js run prod
   28 root      0:00 /usr/local/bin/node /app/node_modules/.bin/cross-env NODE_ENV=production micro -p 3000 dist/serverIndex.js
   35 root      0:00 /usr/local/bin/node /app/node_modules/.bin/micro -p 3000 dist/serverIndex.js
   42 root      0:00 sh
   50 root      0:00 ps
/app # netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN
tcp        0      0 :::3000                 :::*                    LISTEN
tcp        0      0 ::ffff:192.168.118.138:3000 ::ffff:192.168.110.232:40688 TIME_WAIT
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node Path
unix  3      [ ]         STREAM     CONNECTED     275190742
unix  3      [ ]         STREAM     CONNECTED     275190743

Our fix was to revert to 9.4.0 which works fine.
I thought I would post it incase someone else faces this problem.
Meanwhile we are trying to upgrade to node16 to see if 9.4.1 works there.


Update: Node 16 also did not work so we are back to 9.4.0

@pmbanugo
Copy link
Contributor

pmbanugo commented Aug 5, 2022

When you run it locally what kind of errors do you get?

@samarjit
Copy link
Author

samarjit commented Aug 6, 2022

This is reproduceable even in local laptop environment
docker pull public.ecr.aws/docker/library/node:16.16-alpine
docker run -dit

Open a terminal and log into container:
docker exec sh

Run inside container npm i micro@9.4.1
I took the below examples from documentation.

~ # cat > test.js
module.exports = () => {
console.log('server accepted connection');
'Welcome to Micro';
}

node_modules/.bin/micro test.js

Open another terminal and run curl localhost:3000 it gets stuck, even the console log 'server accepted connection' does not gets printed. . If curl is not installed by default run apk add curl.
Some more hint into the issue - If I kill the micro server at this point, then curl says empty response returned from server:

/ # curl http://localhost:3000
curl: (52) Empty reply from server

Another example same symptoms.

~ # cat send.js
const {send} = require('micro')

module.exports = async (req, res) => {
  const statusCode = 400
  const data = { error: 'Custom error message' }

  send(res, statusCode, data)
}

Same thing happens if you run node_modules/.bin/micro send.js.

If you want to compare against 9.4.0 both of the above examples runs fine in 9.4.0. Just run npm i micro@9.4.0 and try rest of the steps they all passes.

Note: I ran docker using docker desktop and I have windows 10 machine, but that should not matter.

@pmbanugo
Copy link
Contributor

pmbanugo commented Aug 9, 2022

I think I found why it isn't working. There was a recent PR that reverted some changes wrongfully, which was was got applied to 9.4.1. You can stick to 9.4.0 or wait until there's a new major release in the coming days/weeks.

It should be resolved in the next 9.5 release.

@electerious
Copy link

This isn't just alpine related. I've tried micro with Node.js v14, v16 and v18 on macOS. Non of them worked with 9.4.1. Downgrading to 9.4.0 fixes the issue. This even effects simple code examples from the README (module.exports = () => 'Welcome to Micro';) when you use the micro CLI.

@pmbanugo
Copy link
Contributor

@electerious As I said in the previous comment, there's an issue with 9.4.1 and I wouldn't recommend using it. Stick to 9.4.0 for the moment 😄

@ranrao
Copy link

ranrao commented Nov 3, 2022

I seem to run into the same issue with 9.4.0 with NodeJS v12. Could anyone please share an example of a Dockerfile to ensure I have it right?

Running curl localhost:3000 gets stuck in the pod. Please help.

@samarjit
Copy link
Author

samarjit commented Nov 5, 2022 via email

@leerob
Copy link
Member

leerob commented Nov 25, 2022

The code has been significantly changed with v10. Please reopen or create a new issue with a reproduction is you are still seeing this issue on v10. Thanks!

@leerob leerob closed this as completed Nov 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants