Coder Social home page Coder Social logo

Comments (2)

mattiash avatar mattiash commented on May 29, 2024

The "problem" is that pumpify uses pump, and the documentation for pump explicitly says:

Combine an array of streams into a single duplex stream using pump and duplexify. If one of the streams closes/errors all streams in the pipeline will be destroyed.

I looked at the code in this module and came up with the following patch:

diff --git a/lib/pino-papertrail.js b/lib/pino-papertrail.js
index 0931f6a..efaedbf 100644
--- a/lib/pino-papertrail.js
+++ b/lib/pino-papertrail.js
@@ -86,7 +86,10 @@ function toPapertrailUdp (options) {
     write (data, encoding, callback) {
       if (options.echo === true) { console.log(data.toString()) }
       socket.send(data, 0, data.length, options.port, options.host, function (err) {
-        callback(err)
+        if(err) {
+          console.log('error', err.message)
+        }
+        callback()
       })
     }
   })

What it does is to not pass the err value to the callback, i.e. just swallow all the data and don't report an error to the callback even if it fails to send the data to papertrail. I think this is an acceptable behavior, since we are using udp anyway and that does not give any guarantees about delivery.

With this patch, pino-papertrail will log an error while DNS lookups fail and then resume sending data to papertrail when DNS lookups work again.

My question is if this is an acceptable approach to you and what I should do with the error. Just logging it to stdout seems reasonable to me.

from pino-papertrail.

ovhemert avatar ovhemert commented on May 29, 2024

LGTM,.. feel free to send a PR

from pino-papertrail.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.