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

Incompatible with Node 14: "Socket is closed" error #58

Closed
davidtheclark opened this issue Oct 14, 2020 · 2 comments
Closed

Incompatible with Node 14: "Socket is closed" error #58

davidtheclark opened this issue Oct 14, 2020 · 2 comments
Labels
bug Something isn't working

Comments

@davidtheclark
Copy link
Contributor

When I try to use this library in a Docker container running Node 14, I hit the following error:

events.js:291
      throw er; // Unhandled 'error' event
      ^
Error [ERR_SOCKET_CLOSED]: Socket is closed
    at Socket._writeGeneric (net.js:774:8)
    at Socket._write (net.js:796:8)
    at writeOrBuffer (_stream_writable.js:352:12)
    at Socket.Writable.write (_stream_writable.js:303:10)
    at /usr/local/src/prauthoxy-platform/node_modules/aws-embedded-metrics/lib/sinks/connections/TcpClient.js:57:56
    at new Promise (<anonymous>)
    at TcpClient.<anonymous> (/usr/local/src/prauthoxy-platform/node_modules/aws-embedded-metrics/lib/sinks/connections/TcpClient.js:52:19)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/src/prauthoxy-platform/node_modules/aws-embedded-metrics/lib/sinks/connections/TcpClient.js:18:58)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
Emitted 'error' event on Socket instance at:
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at errorOrDestroy (internal/streams/destroy.js:167:7)
    at onwriteError (_stream_writable.js:391:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  code: 'ERR_SOCKET_CLOSED'
}

The exact same code usage works just fine on Node 12.

@jaredcnance jaredcnance added the bug Something isn't working label Oct 19, 2020
@springmeyer
Copy link
Contributor

I'm also hitting this problem, blocking my ability to upgrade to node v14. So I dug through the commit history for the net.js code in node core and found this commit from @ronag nodejs/node@eeccd52#diff-218c57e035f64b18af4db037c96f13014aeb40a1f783d4f52919e2075621da0c. I'm not following why the change was made (maybe @ronag can provide some more details?) but I found a workaround which I've put up at #59.

@simonespa
Copy link

Getting the same issue on a Centos7 Linux distro installed on a AWS EC2 instance

throw er; // Unhandled 'error' event
^
Error [ERR_SOCKET_CLOSED]: Socket is closed
at Socket._writeGeneric (net.js:775:8)
at Socket._write (net.js:797:8)
at writeOrBuffer (_stream_writable.js:352:12)
at Socket.Writable.write (_stream_writable.js:303:10)
at /usr/lib/component/node_modules/aws-embedded-metrics/lib/sinks/connections/TcpClient.js:58:56
at new Promise (<anonymous>)
at TcpClient.<anonymous> (/usr/lib/component/node_modules/aws-embedded-metrics/lib/sinks/connections/TcpClient.js:53:19)
at Generator.next (<anonymous>)
at fulfilled (/usr/lib/sounds-radioplayer/node_modules/aws-embedded-metrics/lib/sinks/connections/TcpClient.js:19:58)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Emitted 'error' event on Socket instance at:
at emitErrorNT (internal/streams/destroy.js:106:8)
at errorOrDestroy (internal/streams/destroy.js:168:7)
at onwriteError (_stream_writable.js:391:3)
at processTicksAndRejections (internal/process/task_queues.js:82:21) {
code: 'ERR_SOCKET_CLOSED'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! component@1.49.0 start: `node dist/server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the component@1.49.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Using:

node v14.15.0
npm v6.14.8
aws-embedded-metrics v2.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants