nginx / njs

A subset of JavaScript language to use in nginx
http://nginx.org/en/docs/njs/
BSD 2-Clause "Simplified" License
1.02k stars 147 forks source link

ERR_CONTENT_LENGTH_MISMATCH while sending a long text #760

Open imzlh opened 2 months ago

imzlh commented 2 months ago

Describe the bug

When I try to send a long string(JSON.stringify), the browser reports an error image

To reproduce

Steps to reproduce the behavior:

NJS: Here: https://github.com/imzlh/vlist-njs/blob/master/main.ts#L429

CURL:

*   Trying 192.168.1.1:81...
* Connected to 192.168.1.1 (192.168.1.1) port 81
> POST /@api/?action=slist HTTP/1.1
> Host: 192.168.1.1:81
> User-Agent: curl/8.5.0
> Accept: */*
> Content-Length: 26
> Content-Type: application/x-www-form-urlencoded
>
} [26 bytes data]
< HTTP/1.1 200 OK
< Server: nginx
< Date: Sat, 13 Jul 2024 11:16:55 GMT
< Content-Type: application/json; charset=utf-8
< Content-Length: 33829
< Connection: keep-alive
< Alt-Svc: h3=":444"; h2=":8443"; ma=86400
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Headers: Content-Type, Authorization
<
{ [3798 bytes data]
* transfer closed with 6387 bytes remaining to read
 81 33855   81 27442  100    26   337k    327 --:--:-- --:--:-- --:--:--  339k
* Closing connection
curl: (18) transfer closed with 6387 bytes remaining to read

Expected behavior

Complete JSON string

Your environment

xeioex commented 2 months ago

Hi @imzlh,

Can you please minimize the code so I can reproduce the issue? Also please share the minimal nginx.conf.

imzlh commented 2 months ago

minal version: