trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 675 forks source link

rpc breaks on `Transfer-Encoding: chunked` #2320

Open mxork opened 2 years ago

mxork commented 2 years ago

trufflesuite/ganache:v7.0.2

# network host just for convenience...
docker run -it --rm --network host trufflesuite/ganache:v7.0.2 
# not chunked - OK
curl -vv http://localhost:8545 -H "Content-Type: application/json" --data '{"id":0,"jsonrpc":"2.0","method":"eth_accounts"}'    
*   Trying 127.0.0.1:8545...
* Connected to localhost (127.0.0.1) port 8545 (#0)
> POST / HTTP/1.1
> Host: localhost:8545
> User-Agent: curl/7.80.0
> Accept: */*
> Content-Type: application/json
> Content-Length: 48
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200
< Content-Type: application/json
< Content-Length: 485
< 
* Connection #0 to host localhost left intact
{"id":0,"jsonrpc":"2.0","result":["0x157609c1d4adbfa016b3e2e89d6948c262c55f04","0x5250d86009692dc42901f42a431e6cd619c6bb40","0x4600010d0c9bf5054882839695cf48e348e59734","0x1c874ee0c60b979d65aa2d4e2a5b369463c09804","0x91f3bff1eb3ed88a9b3978ec02ccaa393a0fba05","0x37d2cd0ac2d9e5ec3535baab860037b82d6325e9","0xf1bc0e8a716e106dd0856ee7543ab152ce83d1e4","0xcdfea7d950446c415bd66bcce7079ddc664577e2","0x90261a5cf492debd03ce1390aaabaadace4741ec","0x9ba760a678ef0e24f25f4804a08424cb8ea262aa"]}
# chunked - BAD
curl -vv http://localhost:8545 -H "Content-Type: application/json" -H "Transfer-Encoding: chunked" --data '{"id":0,"jsonrpc":"2.0","method":"eth_accounts"}'    
*   Trying 127.0.0.1:8545...
* Connected to localhost (127.0.0.1) port 8545 (#0)
> POST / HTTP/1.1
> Host: localhost:8545
> User-Agent: curl/7.80.0
> Accept: */*
> Content-Type: application/json
> Transfer-Encoding: chunked
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 400
< Content-Type: text/plain
< Content-Length: 45
< 
* Connection #0 to host localhost left intact
400 Bad Request: Unexpected end of JSON input
davidmurdoch commented 2 years ago

related: https://github.com/uNetworking/uWebSockets.js/issues/669

davidmurdoch commented 2 years ago

I'm able to reproduce. I'm curious what your use case is, do you mind sharing?

mxork commented 2 years ago

No legitimate use case here; I'm using an http/1.1 client library which uselessly opts into using Transfer-Encoding: chunked. I think its fair to say the issue is on the library's side.

Feel free to close.

davidmurdoch commented 2 years ago

Interesting. Ganache should support it so we'll leave it open, thanks!

mxork commented 2 years ago

Related issue: the http server is emitting an invalid HTTP/1.1 status line, eg.:

HTTP/1.1 400

The RFC is quite clear, however (https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1):

        Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF

The Reason-Phrase is allowed to be an empty string, but the separating space is not optional.

I'm unsure whether to open another issue for this, or if https://github.com/uNetworking/uWebSockets.js is where the buck stops.

davidmurdoch commented 2 years ago

We should probably just send back the reason string ourselves, though uWS.js might appreciate an Issue on their side too.

MicaiahReid commented 2 years ago

Closing as won't fix because it doesn't look like https://github.com/uNetworking/uWebSockets.js/issues/669 will get fixed.

uNetworkingAB commented 1 year ago

I'm planning on fixing this. Did not know anyone wanted it fixed.

uNetworkingAB commented 1 year ago

Fixed, will be part of next release