Git Product home page Git Product logo

Comments (4)

LekoArts avatar LekoArts commented on June 2, 2024

Hi, thanks for the issue!

The Partial Prerendering feature is marked as highly experimental:

Warning: Partial Prerendering is an experimental feature and is currently not suitable for production environments.

It also has these gotchas:

Partial Prerendering does not yet apply to client-side navigations. We are actively working on this.

There's a good chance that things are not working because something isn't implemented/right yet in Next.js itself. It's also possible that we'll need to update something on our end. Until this feature is in beta or soon to be released we'll however not spend time on this as things aren't settled just yet.

I'd encourage you to open an issue on Next.js and see what the root cause of the error might be. Thanks!

from javascript.

juliuslipp avatar juliuslipp commented on June 2, 2024

Hey @LekoArts,

Thanks for looking into this. While I see, that this feature is still experimental, I don't agree with your statement that this lies on nexts side.

React throws an error when server features are used (headers, cookies) that is used to determine if a component needs to opt out of static rendering (and will be partially prerendered). Since your implementation uses headers() within a try-catch blog:

Prerendering /_not-found needs to partially bail out because something dynamic was used. React throws a special object to indicate where we need to bail out but it was caught by a try/catch or a Promise was not awaited. These special objects should not be caught by your own try/catch. Learn more: https://nextjs.org/docs/messages/ppr-caught-error
 ⚠ The following error was thrown during build, and may help identify the source of the issue:
 ⨯ Error: Clerk: auth() and currentUser() are only supported in App Router (/app directory).
If you're using /pages, try getAuth() instead.
Original error: Error: This page needs to bail out of prerendering at this point because it used headers. React throws this special object to indicate where. It should not be caught by your own try/catch. Learn more: https://nextjs.org/docs/messages/ppr-caught-error

I see that this feature is still experimental, but I am certain it will make it to prod. and also certain that the implementation will be similar to what it is right now, since they don't want to introduce new apis for this.

Here is the matching lines of code:
https://github.com/clerk/javascript/blob/main/packages/nextjs/src/app-router/server/utils.ts#L4C1-L21C3

A simple solution would be to determine and integrate the new error message into the rethrow block of buildRequestLike and simply rethrow this error as well.

It is indeed annoying, since I would love to use PPR right now and clerk is the only thing holding me back.

Should be a simple fix. Please reopen. Happy to help :)

from javascript.

LekoArts avatar LekoArts commented on June 2, 2024

Okay, if you think that change alone would make it work, then please put up a PR. As I said we have other priorities right now but happy to look at a PR.

You can (quickly) test this yourself locally:

  1. Remove your .next folder
  2. Go into node_modules/@clerk/nextjs/dist/esm/server/utils.js and make your change there
  3. Start the server

from javascript.

juliuslipp avatar juliuslipp commented on June 2, 2024

hey @LekoArts,

Just created a PR. Tested it and fixes the issue :) #2518

Do you roughly know when I can expect it to work with the npm package?

from javascript.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.