content icon indicating copy to clipboard operation
content copied to clipboard

Prerender doesn't work anymore (2.13.0 related)

Open owljacob opened this issue 1 year ago • 4 comments

Environment

Reproduction

  1. Upgrade to 2.13.0
  2. Deploy through GitHub Action to Azure Static Web Apps

Describe the bug

After upgrading to 2.13.0, the prerender exits due to errors

Additional context

No response

Logs

[info] [nitro] Prerendering 2 routes
[log] [nitro]   ├─ /api/_content/cache.1719173388066.json (1998ms)
[log] [nitro]   ├─ / (2057ms)
[log] [nitro]   ├─ /api/_content/query/WQ2sbMtXQZ.1719173388066.json (16ms)
  │ ├── Error: [404] Document not found!
[error] Exiting due to prerender errors.
  at prerender (node_modules/nitropack/dist/chunks/prerender.mjs:218:11)
  at async node_modules/nuxt/dist/index.mjs:3540:7
  at async build (node_modules/nuxt/dist/index.mjs:5333:5)
  at async Object.run (node_modules/nuxi/dist/chunks/build.mjs:94:5)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.6aad497e.mjs:1648:16)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.6aad497e.mjs:1639:11)
  at async runMain$1 (node_modules/nuxi/dist/shared/nuxi.6aad497e.mjs:1777:7) 

[error] Exiting due to prerender errors.
  │ └── Linked from /
[log] [nitro]   ├─ /api/_content/query/IP2VeCTPtf.1719173388066.json (15ms)
[log] [nitro]   ├─ /_payload.json (3ms)
[log] [nitro] 
Errors prerendering:
[log] [nitro]   ├─ /api/_content/query/WQ2sbMtXQZ.1719173388066.json (16ms)
  │ ├── Error: [404] Document not found!
  │ └── Linked from /
[log] [nitro]

owljacob avatar Jun 23 '24 20:06 owljacob

Hi,

I'm also getting this issue.

(...)
ℹ ✓ built in 7.23s                                                    11:11:42 AM
✔ Server built in 7236ms                                              11:11:42 AM
ℹ Initializing prerenderer                                      nitro 11:11:42 AM
ℹ Prerendering 2 routes                                         nitro 11:11:47 AM
  ├─ /api/_content/cache.1719223886273.json (1145ms)             nitro 11:11:48 AM
  ├─ / (1494ms)                                                  nitro 11:11:48 AM
  │ └── Error: [500] 
                                                                 nitro 11:11:54 AM
Errors prerendering:
  ├─ / (1494ms)                                                  nitro 11:11:54 AM
  │ └── Error: [500] 
                                                                 nitro 11:11:54 AM

 ERROR  Exiting due to prerender errors.                               11:11:54 AM

  at prerender (node_modules/nitropack/dist/chunks/prerender.mjs:218:11)
  at async node_modules/nuxt/dist/index.mjs:3540:7
  at async build (node_modules/nuxt/dist/index.mjs:5333:5)
  at async Object.run (node_modules/nuxi/dist/chunks/build.mjs:94:5)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.6aad497e.mjs:1648:16)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.6aad497e.mjs:1639:11)
  at async runMain$1 (node_modules/nuxi/dist/shared/nuxi.6aad497e.mjs:1777:7) 



 ERROR  Exiting due to prerender errors.                               11:11:54 AM

Have no idea how to debug this :-/

ptdev avatar Jun 24 '24 10:06 ptdev

Hey again,

So I've pinpointed the issue to this commit.

When using i18n, the content folder usually doesn't have an index file and instead we split it by language, so all the content folder has are subfolders for each language ( content/en, content/fr, etc).

That commit apparently tries to add a non-existing route to the prerender array, which in turn errors out.

Cheers

ptdev avatar Jun 24 '24 13:06 ptdev

This broke production for us, because / was pre-rendered with staging configuration. What’s the best way to disable pre-rendering of /, or any HTML?

ydnar avatar Jun 28 '24 15:06 ydnar

This broke production for us, because / was pre-rendered with staging configuration. What’s the best way to disable pre-rendering of /, or any HTML?

Switch to the Edge Channel, it was fixed there, after it's released outside, you can switch back to stable.

owljacob avatar Jun 28 '24 15:06 owljacob

can't build in github actions but for some reason facing prerender error in latest version, however building works fine on my macbook m1 on node 20

shivanshtalwar avatar Jul 02 '24 10:07 shivanshtalwar

Facing a similar problem with one main of our projects. By upgrading @nuxt/content from 2.12.1 to 2.13.0 the build usually taking 1 minute on my PC will not reach end. On our gitlab instance it froze our dev branch deployement. Usually it built with 3 minutes, cancelling the task took 41 minutes.

Using @nuxtjs/[email protected] and @nuxt/[email protected] as well.

We are using a root content/ folder with markdown (also subsplitted by languages), json, and other files. As Nuxt V4 is changing the folder structure our way is probably not suitable anymore.

I will likely push back @nuxt/content updates until Nuxt V4 is out with a migration guide to figure out how Nuxt ecosystem is shaping on V4 and how to migrate everything accordingly.

Yves852 avatar Jul 02 '24 10:07 Yves852

Hi,

I am also using nuxt-content, nuxt-i18n and nuxt-image and have this issue fixed if I use the edge channel as suggested by @owljackob

I'm also using future { compatibilityVersion: 4 } that uses the new nuxt v4 folder structure. The content folder remains outside the new "app" folder for v4 and works fine on our end.

Cheers

ptdev avatar Jul 02 '24 11:07 ptdev

I think we experienced this also in https://github.com/nuxt-modules/tailwindcss - reverted in https://github.com/nuxt-modules/tailwindcss/pull/867.

danielroe avatar Jul 02 '24 18:07 danielroe

I’m not sure if this helps or is relevant, but I encountered a similar problem. Everything works perfectly fine locally, but there’s an issue with pre-rendering when deploying on Vercel Edge.

Logs

(...)
[error] [nuxt] [request error] [unhandled] [500] The requested module 'file:///vercel/path0/apps/spotlight/node_modules/vue/server-renderer/index.mjs' does not provide an export named 'renderToString'
  at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)  
  at async ModuleJob.run (node:internal/modules/esm/module_job:191:5)  
  at async ModuleLoader.import (node:internal/modules/esm/loader:336:24)  
  at async Object.handler (./node_modules/h3/dist/index.mjs:1975:19)  
  at async toNodeHandle (./node_modules/h3/dist/index.mjs:2266:7)  
  at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)  
  at async generateRoute (./node_modules/nitropack/dist/chunks/prerender.mjs:116:17)  
  at async Promise.all (index 1)  
  at async runParallel (./node_modules/nitropack/dist/chunks/prerender.mjs:253:3)  
  at async prerender (./node_modules/nitropack/dist/chunks/prerender.mjs:202:3)
[error] [nuxt] [request error] [unhandled] [500] The requested module 'file:///vercel/path0/apps/spotlight/node_modules/vue/server-renderer/index.mjs' does not provide an export named 'renderToString'
  at ModuleJob._instantiate (node:internal/modules/esm/module_job:123:21)  
  at async ModuleJob.run (node:internal/modules/esm/module_job:191:5)  
  at async ModuleLoader.import (node:internal/modules/esm/loader:336:24)  
  at async Object.handler (./node_modules/h3/dist/index.mjs:1975:19)  
  at async toNodeHandle (./node_modules/h3/dist/index.mjs:2266:7)  
  at async ufetch (./node_modules/unenv/runtime/fetch/index.mjs:9:17)  
  at async generateRoute (./node_modules/nitropack/dist/chunks/prerender.mjs:116:17)  
  at async Promise.all (index 1)  
  at async runParallel (./node_modules/nitropack/dist/chunks/prerender.mjs:253:3)  
  at async prerender (./node_modules/nitropack/dist/chunks/prerender.mjs:202:3)
[log] [nitro]   ├─ / (514ms)
  │ └── Error: [500] 
[log] [nitro]   ├─ /api/_content/cache.1720084060703.json (581ms)
[info] [nitro] Prerendered 1 routes in 23.567 seconds
[success] [nitro] Generated public .vercel/output/static
(...)

I’m kind of desperate because I’ve tried everything, including disabling nitro.prerender.failOnError, which partially “solved” the problem but introduced another issue.

I can confirm that downgrading @nuxt/content to 2.12.1 indeed helped 🎉

andrzejkupczyk avatar Jul 04 '24 09:07 andrzejkupczyk

Should be fixed in v.2.13.1

farnabaz avatar Jul 05 '24 09:07 farnabaz

Fixed the problem for us thanks. :+1:

Yves852 avatar Jul 05 '24 12:07 Yves852

Resolved with v2.13.1.

owljacob avatar Jul 05 '24 18:07 owljacob