From cb224e275c025d18bad03e4fed9592c23354c7b2 Mon Sep 17 00:00:00 2001 From: Petr Heinz Date: Tue, 6 Oct 2026 16:25:37 +0200 Subject: [PATCH] T-20356 Correct the comments on the size-limit guard The endpoint does not discard an oversized record silently: it replaces it with a notice row in the source. The guard still pays for itself by not uploading megabytes that cannot land, by reporting where the application can see it and by keeping Stats honest. Co-Authored-By: Claude Fable 5.1 --- shutdown_test.go | 4 ++-- transport.go | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/shutdown_test.go b/shutdown_test.go index 89c88b6..0cd29f6 100644 --- a/shutdown_test.go +++ b/shutdown_test.go @@ -72,8 +72,8 @@ func TestRecordsAfterCloseAreReportedOnce(t *testing.T) { } } -// Found by sending a 12 MiB record to the real endpoint: it answered 2xx and the record never -// appeared, because the per-record limit is enforced after the request is accepted. +// Found by sending a 12 MiB record to the real endpoint: it answered 2xx and replaced the record +// with a notice row in the source, so the client counted as sent what never landed. func TestRecordOverTheSizeLimitIsDroppedBeforeSending(t *testing.T) { server, requests := newServer(t, accepted) errs := &errorList{} diff --git a/transport.go b/transport.go index 33f8051..111f23f 100644 --- a/transport.go +++ b/transport.go @@ -38,8 +38,10 @@ const ( dropReportInterval = 5 * time.Second // maxRecordBytes is Better Stack's limit on one record's uncompressed JSON. The endpoint - // accepts a request whose compressed body fits and discards such a record afterwards - // without a word, so the check has to happen here for the drop to be visible. + // accepts a request whose compressed body fits and then replaces such a record with a + // notice row in the source. Checking here saves uploading megabytes that cannot land, + // reports the drop where the application can see it and keeps Stats honest instead of + // counting the record as sent. maxRecordBytes = 10 << 20 )