Handling DynamoDB BatchWrite Errors in Node.js

So, you’re building a Node.js app to do DynamoDB Batch Writes or better yet, you’re diving into AWS’ Lambda? You want to be a good programmer and handle errors gracefully, right? You came to the right place.

First, how do errors look? Notice how you just get an empty {} when all is good, well here is it how it looks if any items are unprocessed by DynamoDB:

Now, this is really cool because Amazon just perfectly returned all the code you need to do a new batch write.
All you need to do now is write a callback and ideally put in some exponential backoff logic, like so:

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrShare on RedditBuffer this pageDigg thisEmail this to someone
Tell Your Friends

Unzipping with the Zip Gem

EDIT: 8 Oct 2016
I deleted the snippet that was here before as I found it just wasn’t working right in all situations :/.

This blog post by Mark Needham turned out to be exactly what I needed though. With a few tweaks we have it where calling unzip_file will give us an array of every file extracted from our zip file.

Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrShare on RedditBuffer this pageDigg thisEmail this to someone
Tell Your Friends