question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A HTTP error will cause Node.js to exit (non-gracefully)

See original GitHub issue

If a HTTP error occurs (for whatever reason) during a Mollie API Request, Node.js exits, without a way for the end-user to catch the error, i.e.:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: Parse Error
    at CleartextStream.socketOnData (http.js:1583:20)
    at CleartextStream.read [as _read] (tls.js:507:12)
    at CleartextStream.Readable.read (_stream_readable.js:320:10)
    at EncryptedStream.write [as _write] (tls.js:366:25)
    at doWrite (_stream_writable.js:221:10)
    at writeOrBuffer (_stream_writable.js:211:5)
    at EncryptedStream.Writable.write (_stream_writable.js:180:11)
    at write (_stream_readable.js:583:24)
    at flow (_stream_readable.js:592:7)
    at Socket.pipeOnReadable (_stream_readable.js:624:5)

This can/should be prevented by adding a request.on(‘error’, function(err) { … }) handler, and calling the end-user callback function with the appropriate feedback, in the rest client:

https://github.com/mollie/mollie-api-node/blob/master/src/lib/mollie/api/client.coffee#L82-92

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
vernondegoedecommented, Oct 8, 2018

Please use our new @mollie/api-client module, which is completely rewritten to ES6 and fully tested.

You can find information on how to upgrade in our Migration guide.

0reactions
dabroekcommented, May 23, 2017

#18 is addressing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Errors | Node.js v19.3.0 Documentation
const cause = new Error('The remote HTTP server responded with a 500 status'); const symptom ... Often a sign that a socket.end() was...
Read more >
Make node.js not exit on error - Stack Overflow
404 status codes are for HTTP, this question was about a socket server so while you can handle the error however you want,...
Read more >
Let It Crash: Best Practices for Handling Node.js Errors on ...
So as I say in both cases an error event, it's a cause of termination for your Node. js process. Always exit the...
Read more >
How to Exit a Process in Node.js: process.exit() Method
Learn how to terminate a Node.js application in the best possible way. We will explain how to do this with the process.exit() function...
Read more >
nodejs-api/ errors
Applications running in Node.js will generally experience four categories of errors: Standard JavaScript errors such as {EvalError}, { ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found