gin icon indicating copy to clipboard operation
gin copied to clipboard

[BUG] gin context.JSON return bad truncated response occasionally

Open sunxunkang opened this issue 2 years ago • 2 comments

Description

I use gin v1.9.1, but sometimes get bad json response cause by bad chunking data,but when I downgrade gin version to v1.8.2,it's ok, I guess it's a bug of sonic json and chunked encoding

How to reproduce

prepare a big struct more than 200k, use context.JSON to return then test the GET api 3000 times, you can get some bad truncated json response, judge it by postman response size

Expectations

image

Actual result

image

Environment

  • go version: v1.20
  • gin version (or commit ref): v1.9.1
  • operating system: centos7

sunxunkang avatar Oct 08 '23 10:10 sunxunkang

I noticed that the struct I used for json serialization contained combined fields because my struct referenced *appsv1.Deployment, not sure if this is a clue

sunxunkang avatar Oct 09 '23 02:10 sunxunkang

Please add some example code to reproduce the issue. You should be able to write a test for it if it occurs after 3000 reqs

zanmato avatar Oct 12 '23 09:10 zanmato