All Questions
18 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 ...
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 ...
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 ...
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 ...
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
...
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:
...
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 ...
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.
...
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 ...
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 ...
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 ...
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 ...
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 ...
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.
...
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 ...