lmittmann / tint

🌈 slog.Handler that writes tinted (colorized) logs
https://pkg.go.dev/github.com/lmittmann/tint
MIT License
765 stars 37 forks source link

Panic #78

Closed ALX99 closed 1 month ago

ALX99 commented 1 month ago

Occurs when logging many things at the same time.

gateway-1        | panic: runtime error: slice bounds out of range [:4181] with capacity 4096 [recovered]
gateway-1        |      panic: runtime error: slice bounds out of range [4181:4096]
gateway-1        |
gateway-1        | goroutine 4317 [running]:
gateway-1        | bufio.(*Writer).Write(0xc000188000, {0xc00034c000?, 0xa46920?, 0xc000311500?})
gateway-1        |      /usr/local/go/src/bufio/bufio.go:681 +0x1b5
gateway-1        | github.com/lmittmann/tint.(*handler).Handle(_, {_, _}, {{0xc1b176d52840182e, 0x817ac0df, 0xa46920}, {0xc000311500, 0xa6c}, 0x0, 0x0, ...})
gateway-1        |      /go/pkg/mod/github.com/lmittmann/tint@v1.0.5/handler.go:248 +0xe38
gateway-1        | log/slog.(*handlerWriter).Write(0xc00018c000, {0xc000310a80, 0xa6d, 0x0?})
gateway-1        |      /usr/local/go/src/log/slog/logger.go:103 +0x229
gateway-1        | log.(*Logger).output(0xc00010c180, 0x0, 0x2, 0xc00055c8b8)
gateway-1        |      /usr/local/go/src/log/log.go:245 +0x45a
gateway-1        | log.Printf(...)
gateway-1        |      /usr/local/go/src/log/log.go:397
gateway-1        | net/http.(*Server).logf(0xc000568000?, {0x7a4840?, 0x10000?}, {0xc00055c948?, 0x0?, 0x0?})
gateway-1        |      /usr/local/go/src/net/http/server.go:3489 +0xc5
gateway-1        | net/http.(*conn).serve.func1()
gateway-1        |      /usr/local/go/src/net/http/server.go:1948 +0x168
gateway-1        | panic({0x778b80?, 0xc0001d8000?})
gateway-1        |      /usr/local/go/src/runtime/panic.go:785 +0x132
gateway-1        | bufio.(*Writer).Flush(0xc000188000)
gateway-1        |      /usr/local/go/src/bufio/bufio.go:645 +0x166
gateway-1        | bufio.(*Writer).Write(0xc000188000, {0xc00010a800?, 0xa46920?, 0x79d485?})
gateway-1        |      /usr/local/go/src/bufio/bufio.go:683 +0xcd
gateway-1        | github.com/lmittmann/tint.(*handler).Handle(_, {_, _}, {{0xc1b176d528396504, 0x81740db4, 0xa46920}, {0x79d485, 0xe}, 0xfffffffffffffffc, 0x6f9166, ...})
gateway-1        |      /go/pkg/mod/github.com/lmittmann/tint@v1.0.5/handler.go:248 +0xe38
gateway-1        | log/slog.(*Logger).logAttrs(0xc0004627f0, {0x82f618, 0xc00050cdb0}, 0xfffffffffffffffc, {0x79d485, 0xe}, {0xc00055d240, 0x2, 0x2})
gateway-1        |      /usr/local/go/src/log/slog/logger.go:277 +0x1e4
gateway-1        | log/slog.(*Logger).LogAttrs(...)
gateway-1        |      /usr/local/go/src/log/slog/logger.go:195
gateway-1        | github.com/alx99/ika/internal/proxy.setPath(0xc0004627e0, {0xc0001921b8, 0x4})
gateway-1        |      /go/internal/proxy/proxy.go:65 +0x447
gateway-1        | github.com/alx99/ika/internal/proxy.(*Proxy).GetHandler.func1(0xc0004627e0)
gateway-1        |      /go/internal/proxy/proxy.go:47 +0x158
gateway-1        | net/http/httputil.(*ReverseProxy).ServeHTTP(0xc0001e3180, {0x82f1a0, 0xc000516180}, 0xc00012d2c0)
gateway-1        |      /usr/local/go/src/net/http/httputil/reverseproxy.go:433 +0x8dd
gateway-1        | github.com/alx99/ika/middleware.accessLog.func1({0x82f0e0, 0xc00019c2a0}, 0xc00012d2c0)
gateway-1        |      /go/middleware/accessLog.go:20 +0xe5
gateway-1        | net/http.HandlerFunc.ServeHTTP(0x82d2e0?, {0x82f0e0?, 0xc00019c2a0?}, 0xc00055da70?)
gateway-1        |      /usr/local/go/src/net/http/server.go:2220 +0x29
gateway-1        | github.com/alx99/ika/middleware.basicProvider.New.func1({0x82f0e0, 0xc00019c2a0}, 0xc00012d2c0)
gateway-1        |      /go/middleware/middleware.go:28 +0x53
gateway-1        | github.com/alx99/ika/middleware.basicMiddleware.ServeHTTP(0xc00012d180?, {0x82f0e0?, 0xc00019c2a0?}, 0xa67c00?)
gateway-1        |      /go/middleware/middleware.go:36 +0x29
gateway-1        | github.com/alx99/ika/internal/router.MakeRouter.BindNamespace.func2({0x82f0e0, 0xc00019c2a0}, 0xc00012d180)
gateway-1        |      /go/middleware/nsbinder.go:14 +0xc5
gateway-1        | net/http.HandlerFunc.ServeHTTP(0xc0001d4000?, {0x82f0e0?, 0xc00019c2a0?}, 0x6c14b6?)
gateway-1        |      /usr/local/go/src/net/http/server.go:2220 +0x29
gateway-1        | net/http.(*ServeMux).ServeHTTP(0x465d59?, {0x82f0e0, 0xc00019c2a0}, 0xc00012d180)
gateway-1        |      /usr/local/go/src/net/http/server.go:2747 +0x1ca
gateway-1        | net/http.serverHandler.ServeHTTP({0xc00058b2f0?}, {0x82f0e0?, 0xc00019c2a0?}, 0x6?)
gateway-1        |      /usr/local/go/src/net/http/server.go:3210 +0x8e
gateway-1        | net/http.(*conn).serve(0xc000226ea0, {0x82f618, 0xc0001ea420})
gateway-1        |      /usr/local/go/src/net/http/server.go:2092 +0x5d0
gateway-1        | created by net/http.(*Server).Serve in goroutine 20
gateway-1        |      /usr/local/go/src/net/http/server.go:3360 +0x485
lmittmann commented 1 month ago

can you provide the code to reproduce this issue?