Worker Service Binding ReadableStream is disturbed
# workers-help
t
Hello, I am using two workers where one is working as a gateway to validate authentication and does a request to itself as a fallthrough (cf handlers first request, internal request goes to DNS origin) lets call this worker A Calling this worker via service binding from worker B results in a 200 response (using logging i can see that both the worker got the request with a 200 and the origin server logging results a 200) But this result is unreadable since its telling me the following: "This ReadableStream is disturbed (has already been read from), and cannot be used as a body." when i try to read the body. When doing a request from the browser to Worker A everything is working as expected. Path: Worker B -> Worker A -> Worker A (internal dns to kubernetes cluster in azure) I am wondering why the request is unreadable, is this a bug ? i expected the JSON result in the response but all i can see is the status code 200 and eveything else seems empty.
Copy code
response = await context.env.GATEWAY.fetch(gatewayUrl, {
    method: 'GET',
    headers: headersObject,
})
console.log(response.status)
console.log(response.statusText)
const data = await response.json<ResponseJson>()
Worker B calling gateway worker A (last line is crashing the worker with the 'This ReadableStream is disturbed' isssue) Logs:
Copy code
{
      "message": [200],
      "level": "log",
      "timestamp": 1682002303360
    },{
      "message": ["OK"],
      "level": "log",
      "timestamp": 1682002303360
    },{
      "message": ["This ReadableStream is disturbed (has already been read from), and cannot be used as a body."],
      "level": "error",
      "timestamp": 1682002303360
    }
2 Views