Gatling tries to remove missing counterName

Gatling version: 3.14.9
Gatling flavor: java kotlin scala javascript typescript
Gatling build tool: [x ] maven gradle sbt bundle npm

I made sure I’ve update my Gatling version to the latest release
I read the guidelines and how to ask a question topics.
I provided a SSCCE (or at least, all information to help the community understand my topic)
I copied output I observe, and explain what I think should be.

Hello all!

We have encountered an issue where Gatling sometimes produces a large number of errors about missing counter like the following:

2025-12-16 17:14:12,131 DEBUG [gatling-1-27]  i.g.h.c.impl.HttpAppHandler - Read msg='DefaultHttpResponse(decodeResult: success, version: HTTP/1.1)
HTTP/1.1 200 OK
Date: Tue, 16 Dec 2025 15:14:12 GMT
Content-Type: application/json
Server-ID: localhost
Content-Length: 163'
2025-12-16 17:14:12,131 DEBUG [gatling-1-27]  i.g.h.c.impl.HttpAppHandler - Read msg='DefaultLastHttpContent(data: PooledSlicedByteBuf(ridx: 0, widx: 163, cap: 163/163, unwrapped: PooledUnsafeDirectByteBuf(ridx: 317, widx: 317, cap: 1024)), decoderResult: success)'
2025-12-16 17:14:12,131 DEBUG [gatling-1-27]  i.g.h.client.pool.ChannelPool - Offering channel entry ChannelPoolKey{clientId=30770, remoteKey=RemoteKey{targetHostBaseUrl='http://localhost:8080', proxyHost='null', proxyPort=0}} to pool
2025-12-16 17:14:12,131 ERROR [gatling-1-27]  i.gatling.core.session.Session - removeCounter called but attribute for counterName bbf1c784-4f09-4242-a92e-6595eb0ddd48 is missing, please report.
2025-12-16 17:14:12,131 DEBUG [gatling-1-27]  io.gatling.core.action.Exit - End user #30770 

We use various loop constructs in our tests (tryMax, repeat, asLongAs, doWhile), but we do not use any explicit counter names for these loops, nor do we reset the session during loop execution.

Below is an example of one of the loops for which the counter sometimes fails to be removed:

group("groupName")
                .on(
                        randomSwitch().on(
                                percent(60).then(exec(session -> session.set("userId", "1"))),
                                percent(20).then(exec(session -> session.set("userId", "2"))),
                                percent(20).then(exec(session -> session.set("userId", "3")))
                        ),
                        exec(session -> session.set("date", new Date())),
                        exec(session -> session.set("filters", getFiltersMap())),
                        http("Get data")
                                .get("/data")
                                .queryParam("userId", "#{userId}")
                                .queryParamMap("#{filters}")
                                .check(status().is(200))
                                .check(jmesPath("token").optional().saveAs("token")),
                        doIf(session -> session.contains("token")).then(
                                repeat(30).on(
                                        pause(10),
                                        http("Get with token")
                                                .get("/info")
                                                .queryParam("userId", "#{userId}")
                                                .queryParam("date", "#{date}")
                                                .queryParamMap("#{filters}")
                                                .check(status().is(200))
                                                .check(jmesPath("token").optional().saveAs("token")),
                                        exec(session -> session.set("filters", getFiltersMap()))
                                )
                        ));

Could you please take a look if there’s anything in this loop that could explain why the counter sometimes cannot be removed?

Hello,

Sorry but we would need a proper reproducer, meaning something we can run on our side. For example, you could build one hitting https://jsonplaceholder.typicode.com/ or https://httpbin.org/.

Note: there’s nothing in the non-runnable extract you’ve provided that could trigger this issue, you problem is more likely related to complex interactions between multiple embedded loops and exit conditions.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.