wasmerio / winterjs

Winter is coming... ❄️
https://winterjs.org/
MIT License
3.04k stars 53 forks source link

Logging a response consumes request body #18

Open theduke opened 1 year ago

theduke commented 1 year ago

addEventListener('fetch', (req) => {
  req.respondWith(handle(req));
});

async function handle(req) {
  let resp = await fetch("https://wasmer.io");
  console.log(resp);
  const body = await resp.text();
  return new Response('hello');
}

Error:

2023-10-29T13:26:29.872440Z ERROR wasmer_winter::server: could not process request error="Error {\n    context: \"javascript failed\",\n    source: \"Script execution failed: Response body has already been used.\",\n}"