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 rendering page with NextJS (14.0.3, 14.0.4 and 14.1.0) #430

Open
Gr33nLight opened this issue Jan 24, 2024 · 4 comments
Open

Error rendering page with NextJS (14.0.3, 14.0.4 and 14.1.0) #430

Gr33nLight opened this issue Jan 24, 2024 · 4 comments

Comments

@Gr33nLight
Copy link

Hello, I'm trying to render a pdf in a NextJS project.
I created a client component inside a page and I have the starting code to show the PDF.
I'm getting the following error:

Error: Element type is invalid. Received a promise that resolves to: [object Promise]. Lazy element type must resolve to a class or function.
Call Stack
mountLazyComponent
../node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (16721:8)
mountLazyComponent
../node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (18388:15)
beginWork$1
../node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/next/dist/compiled/react-dom/cjs/react-dom.development.js (26791:13)


Apparently this issue also happened with material-ui and amplify with the same version of next
mui/material-ui#40214
aws-amplify/amplify-hosting#3847

I tried downgrading to 14.03 and updating to 14.1 but neither fixed the error, did anyone manage to make it work with NextJS?

@Gr33nLight
Copy link
Author

Update: it appears to be caused by the import of the pdfjs-dist library, still trying to make it work

@Gr33nLight
Copy link
Author

Downgrading to [email protected] fixes the issue.
Also updating the workerSrc to "//unpkg.com/pdfjs-dist@${pdfjs.version}/build/pdf.worker.min.js" because the cloudflare url was giving CORS errors on local dev, I can do a pull request if needed.

@piotrberlowski
Copy link

piotrberlowski commented Mar 6, 2024

Did you open a ticket with pdfjs by any chance? If downgrading works then it might be an issue with upstream? I just hit the same error directly importing pdfjs-dist.

@piotrberlowski
Copy link

This seems known

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants