Most env-var validation checks that values exist. That catches missing config but misses the worse case - a value that is present, valid in shape, and silently wrong. Here is the asymmetric pattern for separating loud failures from silent ones in a Next.js server.
Duncan Leung
📚 Learning, 👨🏻💻 Building, 📝 Documenting...
Hi! I'm Duncan Leung and I currently lead Frontend Engineering at Airvet.
In a previous career I worked overseas in Beijing as a Product Manager at a skunkworks studio building digital experience projects for Ford Motor (China) and consulted on UX projects for Starwood Hotels. During this time I also mentored startups at Chinaccelerator and ran startup events and hackathons in Shanghai.
👨🏻💻 I'm a self taught software developer, and this is a place for me to jot down some notes. I mostly cover Javascript, Typescript, React, and software development.
Latest Writing
- Read article
- Read article
When one Go struct legitimately serves multiple consumer roles - producer, service, admin - declare three interfaces and let DI cache the singleton at the wide type while each consumer holds only the methods it can call. Same shape as io.ReadWriteCloser in the stdlib.
- Read article
Most SQS idempotency guides reach for Redis dedupe keys or dedupe tables. If your worker's job ends in a terminal state-machine transition, the row's own status column is already the lock - and one UPDATE statement is the entire safety story.
- Read article
A talk I gave to the Airvet engineering org on working with AI coding agents - the mental model, context engineering, and the Research → Plan → Implement loop that ties them together.
- Read article
Learn how to configure MCP (Model Context Protocol) servers globally for Claude Code, making them available across all your projects.
Newsletter
Stay updated, receive the latest post straight to your mailbox