Skip to content

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

@Thomasvdam

Description

@Thomasvdam

🐛 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions