Cloud Out Loud Podcast

Episode 3 - Don't Make Promises You Can't Keep


Listen Later

Send us a text

Don't make promises you can't keep - Using Node.ja promises correctly in Google Cloud functions

Episode 03: Show Notes

(Recorded November 18, 2021)

Today Jon and Logan discuss the recent Google Cloud blog “Avoiding GCF anti-patterns part 4: How to handle Promises correctly in your Node.js Cloud Function”, and give their own views on how to go about this. They discuss the scenario outlined in the blog, the two patterns that the blog outlines for fixing this issue, and the origins of their own biases regarding JavaScript, before explaining their own solution to this problem using TypeScript. They also explain how this issue differs from the one they discussed in the last episode ans the importance of code not just running reliably but also being readable and maintainable. Tune in to find out why Jon and Logan are biased towards taking the clouding approach to developing this code, why you should look in the DataFlow if you’re doing an ETL pipeline, why you should reconsider deploying a system based on vanilla node.js, and what you should do if you decide to do it anyway.

Key Points From This Episode:


  • Recent news: The Google outage that occurred this week. 
  • Today’s topic: the blog post “Avoiding GCF anti-patterns part 4: How to handle Promises correctly in your Node.js Cloud Function”
  • An introduction to the scenario outlined in this blog post. 
  • Jon’s biases based on his experiences with JavaScript and its evolution. (And Jon’s embarrassing memory lapse re: AJAX)
  • The two patterns for fixing this issue outlined in the blog post. 
  • The rest of the blog: How to write some methods for logging and integrate those into logic that’s doing the promise database call and retrieval. 
  • Jon and Logan’s bias: Why are you making an asynchronous call to a database?
  • How this issue differs from the one they discussed in the last episode about how to deal with API calls that could take a long time.
  • Promises, their role in JavaScript, and the problem of them being conflated with “vettable” code.
  • The importance of code not just running reliably but being readable and maintainable.
  • Logan’s solution to this problem using TypeScript.
  • Understanding the context of this code in the browser context. 
  • Why Jon and Logan are biased towards taking the cloudy approach to developing this code.
  • Why you should look in the data flow if you’re doing an ETL pipeline.
  • Why you should reconsider deploying a system based on node.js and what you should do if you decide to do it anyway.

Tweetables:

“Writing code that’s difficult to understand, difficult to read, difficult to maintain, you are definitely doing a disservice to your future self or whoever’s in that role in the future.” — @LoganAct2 [0:12:34]

“Be lazy, be cheap. Let the infrastructure help you catch the bugs early with something like TypeScript and collect the bugs in a central place with the Cloud Operations capability ” — @JonGal [0:14:41]

Links Mentioned in Today’s Episode:

Avoiding GCF anti-patterns part 4: How to handle Promises correctly in your Node.js Cloud Function

Typescript Reference

DataFlow

...more
View all episodesView all episodes
Download on the App Store

Cloud Out Loud PodcastBy Jon and Logan Gallagher