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

Unexpected Execution of generateSitemaps Function When Commented Out During Build Process #62343

Open
Akramovic opened this issue Feb 21, 2024 · 3 comments
Labels
bug Issue was opened via the bug report template.

Comments

@Akramovic
Copy link

Akramovic commented Feb 21, 2024

Link to the code that reproduces this issue

https://codesandbox.io/p/devbox/elegant-surf-z8vmmj?file=%2Fapp%2Fsitemap.ts%3A7%2C25

To Reproduce

  1. Add the generateSitemaps function to your sitemap.ts file.
  2. Comment out the generateSitemaps function.
  3. Execute the build process and notice that the build does not succeed, suggesting that the build process is impacted by the commented-out code.

Current vs. Expected behavior

Expected Behavior:
Commenting out the generateSitemaps function should not impact the build process
Actual Behavior:
The generateSitemaps function appears to be parsed resulting to a build error.

Provide environment information

Relavant packages:
"next": "14.0.3",

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

Metadata Files

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

next build (local)

Additional context

No response

@Akramovic Akramovic added the bug Issue was opened via the bug report template. label Feb 21, 2024
@Akramovic Akramovic changed the title Unexpected Execution of generateSitemaps Function When Commented Out Unexpected Execution of generateSitemaps Function When Commented Out During Build Process Feb 22, 2024
@bartoszhernas
Copy link

I have similar bug. I need this to be dynamic sitemap (it accesses database), and yet force-dynamic doesn't stop this from execution during build process.

@bartoszhernas
Copy link

Is there a way to fix it? It seems that now multiple-sitemaps generation will always happen in build time. I am building Fraghead.io which uses Prisma (Postgres) backend, so I do not have access to any data in build time.

@bartoszhernas
Copy link

Temporary fix:
I have encapsulated both functions in try {} catch {}. They will run during build time and fail silently but fortunately they will be dynamically generated in the runtime as well, making it work.

Still, would be better to not call it in build time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue was opened via the bug report template.
Projects
None yet
Development

No branches or pull requests

2 participants