mirror of
https://github.com/fosrl/newt.git
synced 2026-05-06 07:59:04 -05:00
[PR #304] fix: chunk large Docker container lists to prevent WebSocket message loss #1950
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/fosrl/newt/pull/304
Author: @jaydeep-pipaliya
Created: 4/9/2026
Status: 🔄 Open
Base:
main← Head:fix/chunk-docker-container-messages📝 Commits (2)
cf853b1fix: chunk large Docker container lists to prevent WebSocket message loss82523a0fix: add batchId to chunked container messages for concurrency safety📊 Changes
1 file changed (+49 additions, -14 deletions)
View changed files
📝
main.go(+49 -14)📄 Description
What does this PR do?
Companion PR for fosrl/pangolin#2117 — Docker Container View not displaying when >20 containers are running.
Problem
gorilla/websocket.WriteJSONserializes the full container list into a single WebSocket text frame. With 55+ containers (each 1-5KB of JSON metadata), the resulting frame can be 55-275KB. Intermediary proxies (Traefik, nginx, Cloudflare tunnels) can silently drop or truncate frames this large, causing the pangolin server to never receive the container data.Solution
Added
sendContainerList()that automatically chunks large container lists:Why
batchId?Two concurrent container sends can happen when a manual fetch request and a Docker event fire at the same time. Without
batchId, their chunks would interleave and corrupt the accumulated data on the server. Each batch gets a unique ID (reusing the existinggenerateChainIdhelper) so the server can track and supersede batches correctly.Why chunk size of 15?
Each container with full metadata (labels, ports, networks) serializes to 1-5KB. 15 containers ≈ 15-75KB per WebSocket frame — safely under common proxy defaults (Traefik default buffer: 64KB, nginx: 64KB). The threshold was chosen to balance message count vs. frame size.
Changes
main.go:sendContainerList()— chunks large lists, passes small lists through unchangedgenerateChainId()for batch IDs — no new dependenciesCompanion PR
Pangolin server: https://github.com/fosrl/pangolin/pull/2817
batchIdtracking, input validation, typed accumulator, 120s TTL on partial chunksTesting
go buildpasseschunkIndex/totalChunks/batchIdbatchId, server handles superseding🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.