From 05e5595c2b25e328b9bfde98063586a8be0ad3c0 Mon Sep 17 00:00:00 2001 From: Jason Staack Date: Wed, 18 Mar 2026 05:52:09 -0500 Subject: [PATCH] fix(poller): add 64MB cap on DEVICE_EVENTS NATS stream Without a byte limit, the stream grows unbounded within its 24h max_age window. At 101 devices polling every 60s, it hits 128MB in ~10 hours and OOMs the NATS container. Co-Authored-By: Claude Opus 4.6 (1M context) --- poller/internal/bus/publisher.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/poller/internal/bus/publisher.go b/poller/internal/bus/publisher.go index afbc28d..e28f000 100644 --- a/poller/internal/bus/publisher.go +++ b/poller/internal/bus/publisher.go @@ -141,6 +141,8 @@ func NewPublisher(natsURL string) (*Publisher, error) { "audit.session.end.>", }, MaxAge: 24 * time.Hour, + MaxBytes: 64 * 1024 * 1024, // 64MB cap — discard oldest when full + Discard: jetstream.DiscardOld, }) if err != nil { nc.Close()