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

[NEXT-526] appDir on Vercel: Cannot read properties of undefined (reading 'getReader') #45627

Closed
1 task done
pudo opened this issue Feb 6, 2023 · 11 comments
Closed
1 task done
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.

Comments

@pudo
Copy link

pudo commented Feb 6, 2023

Verify canary release

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

Provide environment information

This issue only occurs when deployed on Vercel, I cannot reproduce it locally

Local next info:

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 22.2.0: Fri Nov 11 02:04:44 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8103
Binaries:
  Node: 19.5.0
  npm: 9.3.1
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 13.1.6
  eslint-config-next: N/A
  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)

Link to the code that reproduces this issue

https://github.com/opensanctions/site/tree/main/app/entities/%5BentityId%5D

To Reproduce

I cannot reproduce this bug on my own computer. I've tried the vercel command. I've contacted Vercel support but they told me I should go here because it's appDir. I've tried the following to narrow it down, without success:

  • Removing/commenting out everything in the head.tsx
  • Removing/commenting out everything in the loading.tsx
  • Removing/commenting out everything in the page.tsx
  • Checked all routes to see if null is returned anywhere

The only thing that works is downgrading to next 13.1.1

Describe the Bug

When deploying this site to Vercel, the following error is all over the logs - and API request usage goes up 10x:

[GET] /entities/Q4532737/
19:07:51:88
2023-02-06T18:07:52.006Z	41727f4c-cfa6-48ec-88d3-e451cce93603	ERROR	TypeError: Cannot read properties of undefined (reading 'getReader')
    at /var/task/node_modules/next/dist/server/render-result.js:27:37
    at RenderResult.pipe (/var/task/node_modules/next/dist/server/render-result.js:46:11)
    at Object.sendRenderResult (/var/task/node_modules/next/dist/server/send-payload/index.js:69:22)
    at NextNodeServer.sendRenderResult (/var/task/node_modules/next/dist/server/next-server.js:394:34)
    at NextNodeServer.pipe (/var/task/node_modules/next/dist/server/base-server.js:419:25)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Object.fn (/var/task/node_modules/next/dist/server/next-server.js:759:21)
    at async Router.execute (/var/task/node_modules/next/dist/server/router.js:253:36)
    at async NextNodeServer.run (/var/task/node_modules/next/dist/server/base-server.js:384:29)
    at async NextNodeServer.handleRequest (/var/task/node_modules/next/dist/server/base-server.js:322:20)
RequestId: 41727f4c-cfa6-48ec-88d3-e451cce93603 Error: Runtime exited with error: exit status 1
Runtime.ExitError

Whenever I open the erroring page in the browser, it is displayed without error.

Sometimes the error is also just:

[GET] /entities/NK-c55S959ZVS6JnyQZCzjPPN/
19:07:53:19
RequestId: 73ea2414-0a59-4769-b913-2327be28c231 Error: Runtime exited with error: exit status 1
Runtime.ExitError

Expected Behavior

I expect the page to be rendered without error.

Which browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

Vercel

NEXT-526

@pudo pudo added the bug Issue was opened via the bug report template. label Feb 6, 2023
@skwinnik
Copy link

skwinnik commented Feb 8, 2023

I also experience this issue on Vercel and cannot reproduce it locally. In my case, I see these errors only when google or another search engine crawls my website. But, my app doesn't have a lot of visitors, so may be it's not really specific to crawlers.

@pudo
Copy link
Author

pudo commented Feb 9, 2023

I've subjectively also noticed that a lot of the error messages seem to show a crawler UA. Weird.

@venables
Copy link

venables commented Feb 9, 2023

Thank you! I have been experiencing this issue as well. Anecdotally, it also appears that crawlers receive the most errors, but I have noticed this occurring to (seemingly) regular users as well. Similarly, the API usage reported by Vercel skyrocketed.

Downgrading to next 13.1.1 appears to have fixed the issue. I will slowly increment patch version by patch version to see if I can provide assistance to locating the bug.


Update 1: I can confirm the error occurs on next 13.1.2, so the bug was introduced between 13.1.1 and 13.1.2. I'll try going through the 13.1.2 canary releases to help bisect.

Update 2: In my testing (which is difficult because this error only appears in production on Vercel), it appears that the bug was introduced in next 13.1.2-canary.5. It appears that next 13.1.2-canary.4 works as expected without errors.

@skwinnik
Copy link

skwinnik commented Feb 9, 2023

@venables Thank you for the research! Can you share with us how exactly you tested this? It may be helpful for further research.

@venables
Copy link

venables commented Feb 9, 2023

@skwinnik I tested by simply locking in a version of next and deploying it to my sites on Vercel. The function logs would immediately turn red with the error described in this ticket (TypeError: Cannot read properties of undefined (reading 'getReader')). I was unable to get this error to occur locally, but it's pretty immediate when deployed to production on a site with traffic.

@balazsorban44 balazsorban44 added area: app App directory (appDir: true) type: needs investigation labels Feb 13, 2023
@github-actions github-actions bot added the linear: next Confirmed issue that is tracked by the Next.js team. label Feb 13, 2023
@balazsorban44 balazsorban44 added linear: next Confirmed issue that is tracked by the Next.js team. and removed linear: next Confirmed issue that is tracked by the Next.js team. labels Feb 13, 2023
@balazsorban44 balazsorban44 changed the title appDir on Vercel: Cannot read properties of undefined (reading 'getReader') [NEXT-526] appDir on Vercel: Cannot read properties of undefined (reading 'getReader') Feb 13, 2023
@dluan

This comment was marked as off-topic.

@skwinnik
Copy link

@dluan the error you're facing doesn't appear to be related to the discussion here. It looks like the API you're calling sometimes returns null values, but perhaps it is better to discuss this in another issue.

@shuding
Copy link
Member

shuding commented Feb 23, 2023

Hi @venables could you test it with the latest canary? I think the bug should be fixed in #46265.

@venables
Copy link

@shuding That worked! 🎉 I upgraded to the latest canary (13.1.7-canary-30) and have not seen any errors come through, which used to happen almost immediately upon upgrading past 13.1.1.

Thank you, and everyone else who helped solve this!

@shuding
Copy link
Member

shuding commented Feb 23, 2023

Thank you!

@shuding shuding closed this as completed Feb 23, 2023
@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. 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 Mar 26, 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.
Projects
None yet
Development

No branches or pull requests

6 participants