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

socket.close() is not a function in Node.js 8.x+ #104

Closed
knightcode opened this issue Jun 18, 2018 · 7 comments
Closed

socket.close() is not a function in Node.js 8.x+ #104

knightcode opened this issue Jun 18, 2018 · 7 comments

Comments

@knightcode
Copy link

I found that logging stopped after leaving the process running for some time. This error was printed to the local console:

[winston] Attempt to write logs with no transports {"level":"error","message":"Error getting objectsForIDs:"}
Jun 18 20:26:02 ip-172-31-11-65 nodejs[8718]: Unhandled rejection TypeError: this.socket.close is not a function
Jun 18 20:26:02 ip-172-31-11-65 nodejs[8718]:     at _close (/.../node_modules/winston-syslog/lib/winston-syslog.js:201:23)
Jun 18 20:26:02 ip-172-31-11-65 nodejs[8718]:     at Syslog.close

There is no close method documented on net.Socket here: nodejs.org. There is a destroy method, though.

@peebles
Copy link

peebles commented Aug 16, 2018

I see this too, when using TCP. I also see

Error: Unhandled "error" event. (true)

This is due to line #269

callback(true);

which leads to #136

return callback(err);

which presumably leads to winston doing an emit('error') which I was not listening for. I think maybe line #136 should check to see if err === true, which is really not an error.

Both of these issues (emit(error) and faulty socket.close()) happen only when using TCP.

@massimopibiri
Copy link

Hi guys,
did you find a solution for this problem?

@peebles
Copy link

peebles commented Dec 28, 2018

Its been too long and I don't recall. I know that in general, winston 3.x has given me nothing but trouble and I've usually backed off to winston 2.x, and backed off any plugins so they work with 2.x.
I also remember that at some point I wrote my own "syslog" plugin that did what I wanted. And later, I've started working with AWS cloud watch instead of syslog.

@knightcode
Copy link
Author

See my comment on the other issue I posted. I forked the repo and made a simple fix.

#103 (comment)

@timdp
Copy link

timdp commented Jan 3, 2019

I didn't check with winston 2, but with @knightcode's patch, my Node process doesn't exit after the destroy() call. With require('active-handles').print(), I can see that it's keeping not one but two connections open:

onStreamRead: internal/stream_base_commons.js:87:21 (net client connection, fd = 17)
function onStreamRead(nread, buf) {
  const handle = this;
...
onStreamRead: internal/stream_base_commons.js:87:21 (net client connection, fd = 19)
Count: 2. Source printed above

@cloverb
Copy link

cloverb commented Jun 19, 2019

We're seeing this issue as well using:

Node 10.14.0
winston 3.2.1
winston-syslog 2.1.0

@knightcode's patch appears to resolve the issue.

What kind of repo or logs would you need to see to review either of these PRs @DABH @indexzero?
#109
#112

@DABH
Copy link
Contributor

DABH commented Jul 26, 2019

I've merged the relevant PRs that fix these issues and will cut a v2.2.0. Thanks folks. If you spot other issues related to this, please feel free to open new issues/PRs and I'll see what I can do.

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

6 participants