Bossy Lobster

A blog by Danny Hermes; musing on tech, mathematics, etc.

Edit on GitHub

Wrapping Behavior of context.WithValue()

Motivation

Throughout the Go monorepo we use context.WithValue() to "stash" a global value on a root context. For example

ctx = logger.WithLogger(ctx, log)
// ... later ...
log := logger.GetLogger(ctx)

The implementations for stashing a logger.Log are in the same general form as most context wrapping helpers:

type loggerKey …
Edit on GitHub

Setting Per-Connection Timeouts with TypeORM

PostgreSQL Statement Timeout

For most applications that use a database, user-facing queries must complete in a reasonable amount of time. In order to ensure a maximum query time, PostgreSQL supports a statement_timeout which will cause a query to be cancelled if it exceeds the timeout:

$ psql
monsters_inc=> SHOW statement_timeout;
 statement_timeout …
Edit on GitHub

Fixing the Custom CA Problem in Node.js

TL;DR: Using the ca field to specify custom CAs (certificate authorities) in Node.js is a footgun. It replaces (rather than appends to) the root trust store which can lead to unintended consequences. I've seen this behavior cause outages in production when a third party server does a routine …

Edit on GitHub

The Node.js CA Footgun

Door to Nowhere

This is a story of a brief outage caused by a slightly unintuitive API1 that has some very sharp corners for the uninitiated. The outage, though brief, was of the "wake up at 4am" variety so the lesson was especially salient.

This is not a post trying to tear …