When using chunked responses the server never seems to do the final responseComplete callback. It looks like stage 10 of the server is never being called (which also means the server.connections is never adjusted back down).
I don't not entirely sure, but it seems like maybe the didReceive function in modSocket is getting called with a null pbuf (maybe because it's getting a TCP FIN from the client?). This causes the socket to get set to kPendingDisconnect | kPendingClose.
This kPendingClose overrides all other pending states which means the socket is closed without any callbacks (even the disconnect one). So stage 10 is never called.
(Based on an ESP32 build)