Response is slow when applying filter

When using a connection pool on a client, logging is not performed on a per-request basis, so I am trying to log on a per-payload basis.

I try to use a HAProxy custom filter, but If you send a lot of requests, sometimes the response is slow and errors occur. Moreover, sometimes the process is terminated.

The same situation occurs even if the filter is implemented as shown below. Why is this?

PayloadLog = {}
PayloadLog.id = "Payload Log"
PayloadLog.flags = filter.FLT_CFG_FL_HTX
PayloadLog.__index = PayloadLog

function PayloadLog:new()
    local log = {}
    return log
end

function payloadLogFilter(flt, args)
    return flt
end

core.register_filter('payload-log', PayloadLog, payloadLogFilter)