NextJS error- t.body?.getReader is not a function

Hi guys

It looks like this code can’t be used when the app is build with Edgio.

  const response = await fetch(url);
  const reader = response.body?.getReader();

The above code is working when the app is build with NextJS.

Steps to reproduce:

Full error:

TypeError: t.body?.getReader is not a function
    at u (C:\Git\other\nextnext-app\.edgio\lambda\app\.next\server\pages\api\hello.js:1:563)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async d (C:\Git\other\nextnext-app\.edgio\lambda\app\.next\server\pages\api\hello.js:1:848)
    at async K (C:\Git\other\nextnext-app\.edgio\lambda\app\node_modules\next\dist\compiled\next-server\pages-api.runtime.prod.js:20:16853)
    at async U.render (C:\Git\other\nextnext-app\.edgio\lambda\app\node_modules\next\dist\compiled\next-server\pages-api.runtime.prod.js:20:17492)
    at async NextNodeServer.runApi (C:\Git\other\nextnext-app\.edgio\lambda\app\node_modules\next\dist\server\next-server.js:600:9)
    at async NextNodeServer.handleCatchallRenderRequest (C:\Git\other\nextnext-app\.edgio\lambda\app\node_modules\next\dist\server\next-server.js:269:37)
    at async NextNodeServer.handleRequestImpl (C:\Git\other\nextnext-app\.edgio\lambda\app\node_modules\next\dist\server\base-server.js:816:17)
    at async invokeRender (C:\Git\other\nextnext-app\.edgio\lambda\app\node_modules\next\dist\server\lib\router-server.js:174:21)
    at async handleRequest (C:\Git\other\nextnext-app\.edgio\lambda\app\node_modules\next\dist\server\lib\router-server.js:353:24)

I was able to reproduce this with your test case. I downgraded to 7.10.6 and was able to get it to build make the request successfully.

In 7.11.0, there was a code change that affected the global fetch function, which I think is what is causing this issue. I will create a bug report for this.

1 Like

This issue has been filed under EDGSITES-837. Once I receive an update/resolution, I will follow-up.