Skip to main content

All Questions

2 votes
1 answer
177 views

Command handlers in node.js

Description This javascript code uses tmi.js to listen for chat messages in a Twitch chat and perform certain actions depending on their content. In the sample code ...
Patrick Christie's user avatar
6 votes
1 answer
1k views

Implementation of exponential backoff algorithm

You can read about the algorithm here. An exponential backoff algorithm retries requests exponentially, increasing the waiting time between retries up to a maximum backoff time. An example is: Make ...
sg7610's user avatar
  • 388
2 votes
0 answers
297 views

JavaScript proxy for better stack traces from external libraries

I've been using the excellent pg-promise library for a few years now, but my primary irk with it is that the stack traces are sometimes unhelpful. For example, the following test will fail (currently ...
BrDaHa's user avatar
  • 133
4 votes
1 answer
1k views

Node.js http retry do while mechanism

I have implemented a simple do/while loop to handle a http request to a third-party. I don’t know when the data I receive will have elements in its array so I retry up to 10 times until the array ...
user195155's user avatar
0 votes
2 answers
1k views

Node.js error handling using merely if else without try catch

I'm confused why you need to use try catch. I made a simply utils like this, and use it on my models' callback. in my utils/error.js ...
alex johanson's user avatar
1 vote
2 answers
113 views

Error handling for a simple 'fetch some data, then save the data' Node function

This is a fairly simple bit of code: ...
dwjohnston's user avatar
  • 1,348
0 votes
1 answer
132 views

#Error Handling- Propagating errors to calling function.

Im new to javascript programming and i am required to make a web app. Node.js will be used as the js runtime environment. In order to minimize the amount of time needed for debugging as the app ...
nicholas mitchell's user avatar
3 votes
1 answer
8k views

Mongoose promise & error handling

I search for rails-like way of writing NodeJS code and it's more then hard to find the right way. The code quickly become bloated and unreadable. I would like my code to be as clean as possible. ...
xpepermint's user avatar
5 votes
1 answer
6k views

Node.js callback error pattern

The errors are passed through every callback, but in fact, it might be better to throw an error at higher levels. For example, look at the mongodb.js database function. It passes through an error in ...
onlineracoon's user avatar
4 votes
1 answer
1k views

Loading a database table using a promise chain

I am creating a util module that I'm using to communicate with a MS-SQL database. I want each public method to return a promise. I started with a private function that executes a DB query and returns ...
TimCodes's user avatar
  • 125
1 vote
1 answer
182 views

Hello World Node application with error handling

I wrote this simple server in node. Actually my goal is to better understand exception handling best practices in Node. So my question is more specific. Is this code bullet proof to exceptions? Are ...
user avatar
4 votes
1 answer
1k views

If vs try/catch

The following code, written in synchronous Node.js and intended to be used as a shell script, nests a try/catch inside a conditional. Because both the conditional and the try/catch serve a similar ...
user avatar
3 votes
0 answers
261 views

Keeping error details out of responses (Restify)

I'd like to make sure error details are never sent out in responses from my restify-powered API. The best way to achieve that seemed to be via wrapping server.formatters in another function which ...
Max's user avatar
  • 131
3 votes
0 answers
157 views

Sourcemap translator service

This is my first attempt to a serious Node.js application, I've tried to follow the async style of Node at my best, but I have several doubts and I am sure that this code can be massively improved. ...
Abaco's user avatar
  • 255
4 votes
2 answers
108 views

Writing a user's profile image to disk using nested Node.JS closures

I am writing non-blocking code as it should be in Node.JS. If I want run function A after B I do it using callback. But I find this style guide: Use closures, but don't nest them. Otherwise your ...
Valery's user avatar
  • 381

15 30 50 per page