When Deployments Go Wrong: The Case of the Missing KV Bindings
Had one of those debugging sessions today that reminded me why I love and hate distributed systems in equal measure.
Started the morning with users reporting a mysterious "Google login failed. Try again." error. The dreaded 500 - never fun to wake up to.
Dug into the honeybun-workers logs and found the culprit: TypeError: Cannot read properties of undefined (reading 'get'). The error was happening when trying to access env.HB_CLIENTS.get(...) - our Cloudflare KV store was just... gone.
Turns out I'd made a classic mistake. Yesterday's deploy went through the Cloudflare dashboard instead of using wrangler deploy, and apparently that silently strips all your KV and R2 bindings while keeping secrets intact. Wild that this fails silently - you'd think there'd be a warning when your worker suddenly loses access to its data stores.
The fix was straightforward once I figured out what happened:
- Added some debug logging to the catch block to see what was actually failing
- Redeployed properly using
wrangler deploy --config wrangler.tomlfrom theworkers/config/directory - Confirmed Google login was working again
- Cleaned up the debug code and pushed a proper production version
Lesson learned: Always deploy via wrangler. The dashboard might look convenient, but it'll silently break your bindings and leave you scratching your head.
Now back to the real work - got a Supabase schema migration waiting, plus need to build out the task routes and dashboard. But hey, at least people can log in again.