vercel / next.js

The React Framework
https://nextjs.org
MIT License
125.03k stars 26.71k forks source link

LangChain not compatible with Next.js 14.2.x and causing error in server component rendering. #65140

Closed metaloozee closed 4 months ago

metaloozee commented 4 months ago

Link to the code that reproduces this issue

https://github.com/metaloozee/quickvid

To Reproduce

  1. Start the application using pnpm dev
  2. Try submitting any kind of form and click on the Submit button

NOTE: The error will only show if you are in the development environment.

Current vs. Expected behavior

I've recently integrated langchain into my Next.js project following their installation guide. However, it appears that langchain is not yet compatible with Next.js version 14.2.x. It functions seamlessly with Next.js version 14.1.x.

The issue arises with a peculiar error stating that a class component is being rendered in a server component, despite the absence of any class components in my codebase. My project exclusively employs client components, which are rendered within the app directory of the app.

Interestingly, everything works as expected when I build the project and run it using the start command. However, the error consistently manifests when I run the project using dev --turbo, particularly after submitting any form within the project.

For form functionality, I utilize ui/shadcn along with zod and react-hook-forms.

image

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 11 Home Single Language
Binaries:
  Node: 20.11.1
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant Packages:
  next: 14.1.4
  eslint-config-next: 13.0.0
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.4.5
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local)

Additional context

No response

github-actions[bot] commented 4 months ago

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.