Hi @bernda01,
Thanks a lot for this — and sorry you couldn’t file it on GitHub directly. That was most likely a temporary GitHub glitch on their end, since issue creation is open to everyone on the repo and nothing is restricted on our side. Worth another try if you run into it again.
This was a genuinely good catch. The panic surfaces in k6’s periodic metric flusher with no xk6-tcp frames anywhere in the stack trace, so it’s the kind of report that’s easy to misattribute to k6 itself. You went straight to the actual cause and even pointed at the exact line — that saved us real triage time.
I’ve filed it on your behalf and credited you in the issue:
- Issue: Panic in periodic metric flusher: `nil` `TagSet` pushed on socket read error · Issue #67 · grafana/xk6-tcp · GitHub
- PR: fix: pass current tags when handling read errors by szkiba · Pull Request #68 · grafana/xk6-tcp · GitHub
The PR implements your suggested fix as-is — passing s.currentTags() instead of nil in tcp/socket_read.go — plus a regression test that drives the read loop into a connection reset and asserts the emitted tcp_errors sample carries a non-nil tag set. I verified the test fails without your one-line change, so it should keep this from coming back.
Your diagnosis was correct on every point: the nil reaches the sample’s TimeSeries.Tags via addErrorMetrics, and k6’s summary output then calls Tags.Get on it during the flush. It’s also deterministic rather than a race, io.EOF and timeout errors return earlier in the read loop, so any “real” read error (a connection reset, for instance) triggers it every time.
If filing does keep failing for you, let me know what you’re seeing — an error message, or a missing “New issue” button — and I’ll look into it.
In the meantime, a useful fallback: if you ever can’t open an issue in an extension repo (xk6-tcp, xk6-redis, xk6-kafka, and so on), just file it in the main grafana/k6 repo instead and mention which extension it concerns. We can move it to the right repo from there, so nothing gets lost. The forum works fine too, as this thread shows — but an issue is easier for us to track.
Thanks again for taking the time to track this down properly.
-i2n-