Dashboard stops updating after runtime error (traefik-log-dashboard discussion #52)

ovizii replied in a thread on GitHub to ovizii:

I am getting something similar, the errors start after finally getting this app up and running for like 10 minutes or so, then it starts with:

log-dashboard-backend  | fatal error: concurrent map iteration and map write

I just managed to trigger this error by accessing Plex which is behind traefik by browsing some big libraries.

milindpatel63 commented on GitHub:

I can reproduce this too. As reported by everyone else, it happens when a burst of request come.
Whenever i browse my immich photo library, it sends a lot of request in a very short time, which crashes the backend with the following log

2025/09/20 03:46:53 [WebSocket] Client 20250920-034511-127.0.0.1:11398 sent 100 messages
2025/09/20 03:46:55 [WebSocket] Client 20250920-034511-127.0.0.1:11398 sent 200 messages
2025/09/20 03:46:57 [WebSocket] Client 20250920-034511-127.0.0.1:11398 sent 400 messages
2025/09/20 03:46:58 [WebSocket] Client 20250920-034511-127.0.0.1:11398 sent 500 messages
2025/09/20 03:46:58 [WebSocket] Client 20250920-034511-127.0.0.1:11398 sent 600 messages
fatal error: concurrent map iteration and map write

goroutine 36 [running]:
reflect.mapiterinit(0x454be9?, 0x50?, 0xce50c0?)
        /usr/local/go/src/runtime/map.go:1392 +0x13
reflect.(*MapIter).Next(0xc9bec0?)
        /usr/local/go/src/reflect/value.go:2000 +0x57
encoding/json.mapEncoder.encode({0xffffffffffffffff?}, 0xc0001b7dc0, {0xc9bec0?, 0xc0003523e0?, 0x2?}, {0xa?, 0x0?})
        /usr/local/go/src/encoding/json/encode.go:745 +0x334
encoding/json.structEncoder.encode({{{0xc000370008, 0x18, 0x23}, 0xc0002fe7b0, 0xc0002fe7e0}}, 0xc0001b7dc0, {0xd89d80?, 0xc0003523c0?, 0xc0001b7db0?}, {0x0, ...})
        /usr/local/go/src/encoding/json/encode.go:704 +0x21e
encoding/json.ptrEncoder.encode({0xc0001b7db0?}, 0xc0001b7dc0, {0xc407e0?, 0xc0001b7db0?, 0xc0001b7db0?}, {0x8?, 0x0?})
        /usr/local/go/src/encoding/json/encode.go:876 +0x23c
encoding/json.structEncoder.encode({{{0xc0000da008, 0x4, 0x4}, 0xc0002fe870, 0xc0002fe8a0}}, 0xc0001b7dc0, {0xd25900?, 0xc0001b7d80?, 0x411b1b?}, {0x0, ...})
        /usr/local/go/src/encoding/json/encode.go:704 +0x21e
encoding/json.(*encodeState).reflectValue(0xc0001b7dc0, {0xd25900?, 0xc0001b7d80?, 0x411ec5?}, {0x38?, 0x0?})
        /usr/local/go/src/encoding/json/encode.go:321 +0x73
encoding/json.(*encodeState).marshal(0x411b1b?, {0xd25900?, 0xc0001b7d80?}, {0x71?, 0x0?})
        /usr/local/go/src/encoding/json/encode.go:297 +0xc5
encoding/json.Marshal({0xd25900, 0xc0001b7d80})
        /usr/local/go/src/encoding/json/encode.go:163 +0xd0
main.(*WebSocketClient).sendMessage(0xc0002c01c0, {{0xda70f9, 0x6}, {0xd9a220, 0xc0000fd188}, {0x0, 0x0}, 0xc0003523c0})
        /app/websocket.go:290 +0x10c
main.(*WebSocketClient).sendNewLogWithStats(_, {{0xc0004ad998, 0x18}, {0xc0003e3e80, 0x19}, {0xc00042a9d0, 0xc}, {0xc00042abb8, 0x3}, {0xc0004518b0, ...}, ...})
        /app/websocket.go:359 +0x32a
main.(*WebSocketClient).WritePump(0xc0002c01c0)
        /app/websocket.go:193 +0x745
main.(*WebSocketClient).Start.func1()
        /app/websocket.go:57 +0x49
created by main.(*WebSocketClient).Start in goroutine 49
        /app/websocket.go:49 +0x56

goroutine 1 [chan receive, 1 minutes]:
main.main()
        /app/main.go:169 +0x1398

goroutine 6 [select, 1 minutes]:
github.com/patrickmn/go-cache.(*janitor).Run(0xc0003468f0, 0xc0003d0580) …

milindpatel63 replied in a thread on GitHub to milindpatel63:

I don’t know anything about Go programming language, but i asked cursor to fix this issue, and it modified the logParser.go file and it seems to have fixed it for me.
I have tested upto 0.5 samplerate in traefik.
Here’s the modified file for anyone interested. (Or you could just ask any AI yourself and it will probably fix it)

package main

import (
	"encoding/json"
	"fmt"
	"io"
	"log"
	"math"
	"os"
	"path/filepath"
	"sort"
	"strconv"
	"strings"
	"sync"
	"time"
)

type LogEntry struct {
	ID                      string  `json:"id"`
	Timestamp               string  `json:"timestamp"`
	ClientIP                string  `json:"clientIP"`
	Method                  string  `json:"method"`
	Path                    string  `json:"path"`
	Status                  int     `json:"status"`
	ResponseTime            float64 `json:"responseTime"`
	ServiceName             string  `json:"serviceName"`
	RouterName              string  `json:"routerName"`
	Host                    string  `json:"host"`
	RequestAddr             string  `json:"requestAddr"`
	RequestHost             string  `json:"requestHost"`
	UserAgent               string  `json:"userAgent"`
	Size                    int     `json:"size"`
	Country                 *string `json:"country"`
	City                    *string `json:"city"`
	CountryCode             *string `json:"countryCode"`
	Lat                     *float64 `json:"lat"`
	Lon                     *float64 `json:"lon"`
	
	// Additional fields from the original
	StartUTC                string  `json:"StartUTC,omitempty"`
	StartLocal              string  `json:"StartLocal,omitempty"`
	Duration                int64   `json:"Duration,omitempty"`
	ServiceURL              string  `json:"ServiceURL,omitempty"`
	ServiceAddr             string  `json:"ServiceAddr,omitempty"`
	ClientHost              string  `json:"ClientHost,omitempty"`
	ClientPort              string  `json:"ClientPort,omitempty"`
	ClientUsername          string  `json:"ClientUsername,omitempty"`
	RequestPort             string  `json:"RequestPort,omitempty"`
	RequestProtocol         string  `json:"RequestProtocol,omitempty"`
	RequestScheme           string  `json:"RequestScheme,omitempty"`
	RequestLine             string  `json:"RequestLine,omitempty"`
	RequestContentSize      int     `json:"RequestContentSize,omitempty"`
	OriginDuration          int64   `json:"OriginDuration,omitempty"`
	OriginContentSize       int     `json:"OriginContentSize,omitempty"`
	OriginStatus            int     `json:"OriginStatus,omitempty"`
	DownstreamStatus        int     `json:"DownstreamStatus,omitempty"`
	RequestCount            int     `json:"RequestCount,omitempty"`
	GzipRatio               float64 `json:"GzipRatio,omitempty"`
	Overhead                int64   `json:"Overhead,omitempty"`
	RetryAttempts           int     `json:"RetryAttempts,omitempty"`
	TLSVersion              string  `json:"TLSVersion,omitempty"`
	TLSCipher               string  `json:"TLSCipher,omitempty"`
	TLSClientSubject …

orlovds commented on GitHub:

@​hhftechnology Maybe we can trust the AI? :slight_smile:

hhftechnology replied in a thread on GitHub to orlovds:

Almost done testing the new rewrite where you will get cli agent and dashboard

hhftechnology commented on GitHub:

@​orlovds @​dlhall111 @​plakun @​ovizii @​milindpatel63 V2 should solve all the issues

orlovds commented on GitHub:

@​hhftechnology Thank you so much, it’s running, it’s working!

plakun commented on GitHub:

@​hhftechnology thx. Waiting for documentation fixes for new version.

hhftechnology replied in a thread on GitHub to plakun:

traefik-log-dashboard/docs/MigrationV1toV2.md at main · hhftechnology/traefik-log-dashboard · GitHub