Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Passing the request body directly as a readable stream breaks #12

Open
Thomasvdam opened this issue Aug 27, 2024 · 0 comments
Open

Comments

@Thomasvdam
Copy link
Member

🐛 Bug Report

We noticed that with a particular upstream the requests would return an empty response when we directly forward the request body to the new fetch call without consuming the stream ourselves.

Steps to Reproduce

Run the data proxy (easier without the proof mechanism, but doesn't impact the bug) with the config from the section below.

Make a request to the proxy

curl -d '{ "method": "eth_call", "params": [ { "to": "0x49df0b296903e5d929716fff784b5ed2fa465f43", "data": "0x50d25bcd0000000000000000000000000000000000000000000000000000000000000001" }, "latest" ], "id": 1, "jsonrpc": "2.0" }' -H "Content-Type: application/json" -X POST LOCAL_PROXY_ADDRESS/proxy/

Code snippet to reproduce

Use the following config.json:

{
    "routeGroup": "proxy",
    "routes": [
        {
            "path": "/*",
            "upstreamUrl": "https://<RPC_URL_here>",
            "method": ["GET", "POST"],
            "headers": {
                "accept": "application/json"
            }
        }
    ]
}

Check with Jasper or Thomas for a valid URL.

Stack trace & error message

The proxy will receive an empty response, but no error:

{
  ok: true,
  url: "",
  status: 200,
  statusText: "OK",
  headers: Headers {
    "access-control-allow-credentials": "true",
    "access-control-allow-headers": "Content-Type,Authorization,User-Agent",
    "access-control-allow-methods": "GET, POST, OPTIONS",
    "content-type": "application/json",
    "vary": "Accept-Encoding",
    "date": "Tue, 27 Aug 2024 10:33:55 GMT",
    "content-length": "0",
    "x-node-id": "base_base-sepolia_fra",
  },
  redirected: false,
  bodyUsed: false,
  Blob (0 KB)
}

Expected Behavior

There shouldn't be a difference between transparently forwarding the ReadableStream or consuming the stream as a string and sending that.

Your Environment

  • Latest
  • Bun 1.1.26
  • N.A.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant