Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: invariant: Expected pageData to be a string for app data request but received undefined. This is a bug in Next.js. #47805

Closed
1 task done
llorenspujol opened this issue Apr 1, 2023 · 23 comments · Fixed by #52581
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked Pages Router Related to Pages Router. Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@llorenspujol
Copy link

llorenspujol commented Apr 1, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 16.19.0
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.2.4
      eslint-config-next: 13.0.0
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true), Data fetching (gS(S)P, getInitialProps), Middleware / Edge (API routes, runtime)

Link to the code that reproduces this issue

I cannot reproduce it locally.

To Reproduce

I don't know exactly how to reproduce it locally, it seems to happen only when deployed on Vercel.

Describe the Bug

When executing a serverless function, I am getting the error Error: invariant: Expected pageData to be a string for app data request but received undefined. This is a bug in Next.js. approximately 50% of the times. This error seems to happen only when deployed on vercel. I see the error just by checking the logs.
It seems a bug in the cachedData, since this code is what is giving this error: https://github.com/vercel/next.js/pull/46204/files

Here is the Serverless execution success and fail chart by day, almost 50% fails due to this error.
image

Here is a full error example found in the "Logs":

2023-04-01T22:34:02.255Z	undefined	INFO	info  - Loaded env from /var/task/.env.production
Error: invariant: Expected pageData to be a string for app data request but received undefined. This is a bug in Next.js.
    at NextNodeServer.renderToResponseWithComponentsImpl (/var/task/node_modules/next/dist/server/base-server.js:1013:27)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async NextNodeServer.renderPageComponent (/var/task/node_modules/next/dist/server/base-server.js:1072:24)
    at async NextNodeServer.renderToResponseImpl (/var/task/node_modules/next/dist/server/base-server.js:1098:32) {
  page: '/front-end-jobs-in-antwerp'
}
RequestId: 3193f9ce-3d2b-493d-b5f4-6d8c4c407b22 Error: Runtime exited with error: exit status 1
Runtime.ExitError

Expected Behavior

I expect the cache to work as expected and to have no errors in the serveless function executions. My external backend service , where the serverless function gets the data, does not fail, so the expected behaviour is that the serveless function gets the data and cache it as expected.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1391

@llorenspujol llorenspujol added the bug Issue was opened via the bug report template. label Apr 1, 2023
@github-actions github-actions bot added area: app App directory (appDir: true) Pages Router Related to Pages Router. Runtime Related to Node.js or Edge Runtime with Next.js. labels Apr 1, 2023
@certmates
Copy link

certmates commented Apr 12, 2023

Seeing the same issue, specifically for Google web crawling.

TYPE: Serverless Function

Error: invariant: Expected pageData to be a string for app data request but received undefined. This is a bug in Next.js.
    at NextNodeServer.renderToResponseWithComponentsImpl (/var/task/node_modules/next/dist/server/base-server.js:1013:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async NextNodeServer.renderPageComponent (/var/task/node_modules/next/dist/server/base-server.js:1072:24)
    at async NextNodeServer.renderToResponseImpl (/var/task/node_modules/next/dist/server/base-server.js:1098:32) {
  page: 'X'
}
RequestId: X Error: Runtime exited with error: exit status 1
Runtime.ExitError

@hk86
Copy link

hk86 commented Apr 30, 2023

I'm seeing this as well. Someone found the issue?

@iamsoltan
Copy link

me too

@ijjk
Copy link
Member

ijjk commented May 18, 2023

Hi, can you please confirm this is still an issue in the latest version of Next.js v13.4.3-canary.2? If so please provide a minimal reproduction to allow investigation!

@certmates
Copy link

Hi @ijjk,

Sorry for the delay. New version broke some unrelated functions for me.

I previously had a ~90% fail rate on requesting Google indexing. I have tried 10 times since updating and it failed just once. I will monitor over the next days.

Thank you.

@l-you
Copy link

l-you commented May 30, 2023

NextJs 13.4.3
Still getting this error sometimes.
Deployment to Vercel.

Error occurs only for User Agent
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36 Google-PageRenderer Google (+https://developers.google.com/+/web/snippet/)

@jmikrut
Copy link
Contributor

jmikrut commented May 30, 2023

We're seeing this quite frequently with our website (https://payloadcms.com) all of a sudden.

It happens on different pages each time we deploy, but typically one of these three pages is broken:

https://payloadcms.com/cloud-pricing
https://payloadcms.com/compare/contentful
https://payloadcms.com/for-enterprise

Pages are broken when you navigate directly to the URLs, but the pages work if you navigate to them via links on the website (in the header / footer via next/link.)

This only happens when deployed to Vercel. Can't reproduce running in production locally.

@llorenspujol
Copy link
Author

@ijjk still happening with Next.js v13.4.4

@jmikrut
Copy link
Contributor

jmikrut commented Jun 6, 2023

For everyone else's visibility, we opened a Vercel help discussion here:

https://github.com/orgs/vercel/discussions/2677

@ijjk
Copy link
Member

ijjk commented Jun 10, 2023

Hi, this has been updated in v13.4.5 of Next.js please update and give it a try!

@ijjk ijjk closed this as completed Jun 10, 2023
@austintreneff
Copy link

Just a heads up here.. I was still experiencing the issue on v13.4.5 but v13.4.6 seems to have fixed it.

@francofantini
Copy link

Hi there, I'm still seeing these error logs in production using v13.4.6

Error: invariant: Expected pageData to be a string for app data request but received undefined. This is a bug in Next.js.
at NextNodeServer.renderToResponseWithComponentsImpl (/var/task/node_modules/next/dist/server/base-server.js:1274:27)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async NextNodeServer.renderPageComponent (/var/task/node_modules/next/dist/server/base-server.js:1333:24)
at async NextNodeServer.renderToResponseImpl (/var/task/node_modules/next/dist/server/base-server.js:1365:32)
at async NextNodeServer.pipeImpl (/var/task/node_modules/next/dist/server/base-server.js:641:25)
at async Object.fn (/var/task/node_modules/next/dist/server/next-server.js:1139:21)
at async Router.execute (/var/task/node_modules/next/dist/server/router.js:315:32)
at async NextNodeServer.runImpl (/var/task/node_modules/next/dist/server/base-server.js:615:29)
at async NextNodeServer.handleRequestImpl (/var/task/node_modules/next/dist/server/base-server.js:546:20) {
page: '/categorias/lamparas'
}
RequestId: 065834d7-2433-4378-8637-e8b243f845c2 Error: Runtime exited with error: exit status 1
Runtime.ExitError

Anyone else?

@llorenspujol
Copy link
Author

Same, still happening with v13.4.6.

I think we should re-open the issue.

@logansparlin
Copy link

This is happening for me on v13.4.7

@timneutkens timneutkens reopened this Jul 4, 2023
@timneutkens timneutkens added the linear: next Confirmed issue that is tracked by the Next.js team. label Jul 4, 2023
@ijjk
Copy link
Member

ijjk commented Jul 5, 2023

Can anyone reporting this is still occurring provide a deployment or repo with reproduction where they are seeing it?

The confirmed cases of this have all been resolved and are working properly in the latest version of Next.js

@steve-marmalade
Copy link

@ijjk , here is a deployment running 13.4.9-canary.2 where I am continuing to see this issue: https://web-rcvmm3c6s-marmalade.vercel.app/. The requested URL was https://www.marmalade.co/shop-small?exp=directS2

START RequestId: 6596f190-b28a-45a0-9805-72839a735556 Version: $LATEST
2023-07-06T20:08:18.518Z	6596f190-b28a-45a0-9805-72839a735556	ERROR	Error: invariant: Expected pageData to be a string for app data request but received undefined. This is a bug in Next.js.
    at NextNodeServer.renderToResponseWithComponentsImpl (/var/task/node_modules/next/dist/server/base-server.js:1289:27)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async NextNodeServer.renderPageComponent (/var/task/node_modules/next/dist/server/base-server.js:1348:24)
    at async NextNodeServer.renderToResponseImpl (/var/task/node_modules/next/dist/server/base-server.js:1380:32)
    at async NextNodeServer.pipeImpl (/var/task/node_modules/next/dist/server/base-server.js:641:25)
    at async Object.fn (/var/task/node_modules/next/dist/server/next-server.js:1158:21)
    at async Router.execute (/var/task/node_modules/next/dist/server/router.js:315:32)
    at async NextNodeServer.runImpl (/var/task/node_modules/next/dist/server/base-server.js:615:29)
    at async NextNodeServer.handleRequestImpl (/var/task/node_modules/next/dist/server/base-server.js:546:20) {
  page: '/%7B%22emailVerified%22%3Afalse%2C%22experiment%22%3A%22directS2%22%2C%22isLoggedIn%22%3Afalse%2C%22isWebview%22%3Afalse%7D/shop-small'
}
RequestId: 6596f190-b28a-45a0-9805-72839a735556 Error: Runtime exited without providing a reason
Runtime.ExitError
END RequestId: 6596f190-b28a-45a0-9805-72839a735556
REPORT RequestId: 6596f190-b28a-45a0-9805-72839a735556	Duration: 191.80 ms	Billed Duration: 192 ms	Memory Size: 1024 MB	Max Memory Used: 146 MB

The UserAgent making the request was Googlebot

Mozilla/5.0 (Linux; Android 6.0.1; Nexus 5X Build/MMB29P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.5735.179 Mobile Safari/537.36 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)

ijjk added a commit that referenced this issue Jul 12, 2023
This ensures we don't bail from static generation unexpectedly due to a
bot request as this shouldn't affect ISR handling.

Test deployment with patch can be seen here
https://test-app-isr-fallback-dwn2neok6-vtest314-ijjk-testing.vercel.app/new

Fixes: #47805
@ijjk
Copy link
Member

ijjk commented Jul 12, 2023

Hi, this has been updated in v13.4.10-canary.3 of Next.js, please update and give it a try!

@Galanthus
Copy link

Hi, this has been updated in v13.4.10-canary.3 of Next.js, please update and give it a try!

Still not working and returning the same error in production on Vercel. Tested on latest 3 versions.

@Galanthus
Copy link

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: win32
      Arch: x64
      Version: Windows 10 Pro
    Binaries:
      Node: 16.19.0
      npm: N/A
      Yarn: N/A
      pnpm: N/A
    Relevant packages:
      next: 13.2.4
      eslint-config-next: 13.0.0
      react: 18.2.0
      react-dom: 18.2.0

Which area(s) of Next.js are affected? (leave empty if unsure)

App directory (appDir: true), Data fetching (gS(S)P, getInitialProps), Middleware / Edge (API routes, runtime)

Link to the code that reproduces this issue

I cannot reproduce it locally.

To Reproduce

I don't know exactly how to reproduce it locally, it seems to happen only when deployed on Vercel.

Describe the Bug

When executing a serverless function, I am getting the error Error: invariant: Expected pageData to be a string for app data request but received undefined. This is a bug in Next.js. approximately 50% of the times. This error seems to happen only when deployed on vercel. I see the error just by checking the logs. It seems a bug in the cachedData, since this code is what is giving this error: https://github.com/vercel/next.js/pull/46204/files

Here is the Serverless execution success and fail chart by day, almost 50% fails due to this error. image

Here is a full error example found in the "Logs":

2023-04-01T22:34:02.255Z	undefined	INFO	info  - Loaded env from /var/task/.env.production
Error: invariant: Expected pageData to be a string for app data request but received undefined. This is a bug in Next.js.
    at NextNodeServer.renderToResponseWithComponentsImpl (/var/task/node_modules/next/dist/server/base-server.js:1013:27)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async NextNodeServer.renderPageComponent (/var/task/node_modules/next/dist/server/base-server.js:1072:24)
    at async NextNodeServer.renderToResponseImpl (/var/task/node_modules/next/dist/server/base-server.js:1098:32) {
  page: '/front-end-jobs-in-antwerp'
}
RequestId: 3193f9ce-3d2b-493d-b5f4-6d8c4c407b22 Error: Runtime exited with error: exit status 1
Runtime.ExitError

Expected Behavior

I expect the cache to work as expected and to have no errors in the serveless function executions. My external backend service , where the serverless function gets the data, does not fail, so the expected behaviour is that the serveless function gets the data and cache it as expected.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

NEXT-1391

Have you ever managed to solve this?

@BorisBarzotto
Copy link

Error occurs in 13.4.10 too

@TrustyTechSG
Copy link

TrustyTechSG commented Aug 10, 2023

Error occurs in 13.4.13. randomly see error below from vercel log.

Error: invariant: Expected pageData to be a string for app data request but received undefined. This is a bug in Next.js.

@TrustyTechSG
Copy link

Error occurs in 13.4.13. randomly see error below from vercel log.

Error: invariant: Expected pageData to be a string for app data request but received undefined. This is a bug in Next.js.

Just found out in my case, this error only happen when opening the site in puppeteer.

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: app App directory (appDir: true) bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked Pages Router Related to Pages Router. Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

Successfully merging a pull request may close this issue.