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

Issue with using bunyan and node-config in Node > 8.8.1 #571

Open
jure opened this issue Jan 3, 2018 · 0 comments
Open

Issue with using bunyan and node-config in Node > 8.8.1 #571

jure opened this issue Jan 3, 2018 · 0 comments

Comments

@jure
Copy link

jure commented Jan 3, 2018

So this is a bit of a combo issue, so I wasn't quite sure where to open it, but I think this might be the right place and I'll explain why.

So we're using node-config to configure our bunyan logger like so:

{ 
  'server':  
    'logger': require('bunyan').createLogger({name: 'test'})
}

In node versions below 8.8.1 this works fine. Starting in node version 8.9.0, it fails, in different ways:

    TypeError: Method bytesRead called on incompatible receiver #<Pipe>
      
      at Socket.bytesRead (net.js:659:38)
      at _clone (node_modules/config/lib/config.js:1210:33)
      at _clone (node_modules/config/lib/config.js:1210:20)
      at _clone (node_modules/config/lib/config.js:1210:20)
      at Config.cloneDeep (node_modules/config/lib/config.js:1217:10)
      at node_modules/config/lib/config.js:1477:32
          at Array.forEach (<anonymous>)
      at Config.Object.<anonymous>.util.extendDeep (node_modules/config/lib/config.js:1454:9)
      at Config.Object.<anonymous>.util.setModuleDefaults (node_modules/config/lib/config.js:414:8)
      at Object.<anonymous> (src/index.js:9:13)

After much discussion, it seems that this way (throwing) will remain for the foreseeable future (nodejs/node#17636 and friends linked in there) in these situations.

Now the reason I'm opening this issue on bunyan, and not node_config or Node.js, is that the above configuration works OK with winston.

This is an example of it happening manually (node-config accesses this property automatically):

> const b = require('bunyan').createLogger({name: 'test'})
> b.streams[0].stream._handle.__proto__.bytesRead
TypeError: Method bytesRead called on incompatible receiver #<TTY>

It seems to me that Winston doesn't expose this stream and its _handle in the same way or at all. I'm happy to figure out how to fix this in bunyan, if you think it's an issue/worth fixing. On our end, we've unfortunately had to temporarily remove support for 'bunyan' in our logger config.

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

1 participant