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[DYNAMIC_SERVER_USAGE]: DYNAMIC_SERVER_USAGE with generateStaticParams and Server Components (Next.js 14) on navigating to individual Job details Page. #106

Closed
lalitdotdev opened this issue Apr 20, 2024 · 1 comment
Assignees
Labels
bug Something isn't working moderate Indicates a task of moderate complexity. no-issue-activity

Comments

@lalitdotdev
Copy link
Owner

lalitdotdev commented Apr 20, 2024

Error: DYNAMIC_SERVER_USAGE in Individual Job Page Component (Next.js 14)

Description:

Encountering a 500 Internal Server Error when rendering my individual job page component in production on Vercel. I'm currently using generateStaticParamsto generate potential paths for job pages. However, I understand thatgenerateStaticParams creates static pages at build time, which might be conflicting with the dynamic nature of server components.

Steps to Reproduce:

  1. Visit the individual job page on the development server (usually http://localhost:3000). The page renders correctly.
  2. Deploy the application to Vercel.
  3. Access the individual job page on Vercel. The 500 error occurs.

Relevant Code:

// JobDetailsPage.js
import { getJob } from "@/lib/db"; // Assuming your data fetching logic is in `db.js`

export async function generateStaticParams() {
    const jobs = await db.job.findMany({
        where: {
            approved: true,
        },
        select: {
            slug: true,
        },
    });
    return jobs.map(({ slug }) => slug);
}

function JobDetailsPage({ job }) {
    // Use the fetched `job` data for rendering
    ...
}

Logs :

 ⨯ [Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
  digest: 'DYNAMIC_SERVER_USAGE',
  page: '/jobs/full-stack-developer-at-apple-7'
}
[Error: An error occurred in the Server Components render. The specific message is omitted in production builds to avoid leaking sensitive details. A digest property is included on this error instance which may provide additional details about the nature of the error.] {
  digest: 'DYNAMIC_SERVER_USAGE',
  page: '/jobs/full-stack-developer-at-apple-7'
}
Error: Runtime exited with error: exit status 1

Expected Behavior:

The job page should dynamically fetch job details based on the URL slug and render accordingly. I want the page to function dynamically, updating the content based on incoming requests.

@lalitdotdev lalitdotdev added bug Something isn't working moderate Indicates a task of moderate complexity. labels Apr 20, 2024
@lalitdotdev lalitdotdev self-assigned this Apr 20, 2024
Copy link

Stale issue message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working moderate Indicates a task of moderate complexity. no-issue-activity
Projects
None yet
Development

No branches or pull requests

1 participant