UNEXPECTED END OF JSON

Hi, Whenever I make API calls through my next js server hosted on cloudflare pages, I am constantly receiving the error Unexpected end of JSON input when reading await response.json(). I dont know if my servers are being overwhelemed, the api request always works because im testing it on postman. There is something going on, when sending requests from the api. For more info, the request is being sent to my external heroku server. any ideas?
6 Replies
Hard@Work
Hard@Work4w ago
What do you see if you do response.text()?
solbass
solbass4w ago
it's empty, but it's wierd because when i spam the same request from postman it always works
Hard@Work
Hard@Work4w ago
Do you have the same headers?
solbass
solbass4w ago
yeah
Hard@Work
Hard@Work4w ago
Can you share the project?
solbass
solbass4w ago
"@cloudflare/next-on-pages": "^1.9.0",
"@cloudflare/workers-types": "^4.20240208.0",
"next": "14.1.3",
"next-auth": "^5.0.0-beta.13",
"next-themes": "^0.2.1",
"@cloudflare/next-on-pages": "^1.9.0",
"@cloudflare/workers-types": "^4.20240208.0",
"next": "14.1.3",
"next-auth": "^5.0.0-beta.13",
"next-themes": "^0.2.1",
i'm going to try one more fix, and see how it goes for a day. just wanted to bring up this issue to see if this was a common theme amongst a lot of users thank you for help will keep you updated one of my devs created a fetch wrapper so prob an issue lying in there do you know what could be triggering this issue?
{
"truncated": false,
"outcome": "ok",
"scriptVersion": {
"id": "0fe3f0fc-fa40-42c0-b926-9e4dc314cf99"
},
"scriptName": "pages-worker--2901262-production",
"diagnosticsChannelEvents": [],
"exceptions": [],
"logs": [
{
"message": [
"Error: The 'cache' field on 'RequestInitializerDict' is not implemented."
],
"level": "error",
"timestamp": 1727449423310
},
{
"message": [
"Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error."
],
"level": "error",
"timestamp": 1727449423310
}
],
{
"truncated": false,
"outcome": "ok",
"scriptVersion": {
"id": "0fe3f0fc-fa40-42c0-b926-9e4dc314cf99"
},
"scriptName": "pages-worker--2901262-production",
"diagnosticsChannelEvents": [],
"exceptions": [],
"logs": [
{
"message": [
"Error: The 'cache' field on 'RequestInitializerDict' is not implemented."
],
"level": "error",
"timestamp": 1727449423310
},
{
"message": [
"Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error."
],
"level": "error",
"timestamp": 1727449423310
}
],
i have cache: 'no-store' on all my requests the request is being called in a 'use server' file btw @Hard@Work | R2
Want results from more Discord servers?
Add your server