harlan-zw / nuxt-seo

The complete SEO solution for Nuxt.
https://nuxtseo.com
MIT License
1.11k stars 70 forks source link

Prerender error on Vercel Edge with latest `@nuxtjs/robots` version #273

Closed andrzejkupczyk closed 4 months ago

andrzejkupczyk commented 4 months ago

Describe the bug

I wasn't sure whether to create an issue here or in the @nuxtjs/robots repo 😬
I’ve been using @nuxtjs/robots 3.0.0 so far but decided to switch to @nuxtjs/seo 2.0.0-rc.15.
Everything works perfectly fine in my local environment, but deploying to Vercel gives me this error:

[info] [nitro] Initializing prerenderer
[info] [nitro] Prerendering 1 routes
[error] [unhandledRejection] urls.forEach is not a function
  at .nuxt/prerender/chunks/runtime.mjs:2989:10
[warn] This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
[error] TypeError: urls.forEach is not a function
    at file:///vercel/path0/apps/spotlight/.nuxt/prerender/chunks/runtime.mjs:2989:10
[error] [nitro] [unhandledRejection] urls.forEach is not a function
  at .nuxt/prerender/chunks/runtime.mjs:2989:10
[log] [nitro]   ├─ /api/_content/cache.1721151996320.json (494ms)
[info] [nitro] Prerendered 1 routes in 38.51 seconds
[success] [nitro] Generated public .vercel/output/static

Unfortunately, these errors prevents edge runtime to serve the site. What helped:

I tried to configure the module using both Robots.txt and Nuxt Config.
These findings suggest there may be an issue with the recent Robots version. I’m happy to provide more details if needed.

Reproduction

No response

System / Nuxt Info

- Operating System: `Darwin`
- Node Version:     `v20.10.0`
- Nuxt Version:     `3.12.3`
- CLI Version:      `3.12.0`
- Nitro Version:    `2.9.7`
- Package Manager:  `npm@10.2.3`
- Builder:          `-`
- User Config:      `debug`, `devtools`, `experimental`, `future`, `typescript`, `app`, `alias`, `css`, `compatibilityDate`, `hooks`, `modules`, `routeRules`, `runtimeConfig`, `cookieConsent`, `content`, `dayjs`, `googleFonts`, `gtm`, `image`, `i18n`, `lodash`, `ogImage`, `seoExperiments`, `schemaOrg`, `linkChecker`, `security`, `site`, `sitemap`, `supabase`, `nitro`, `veeValidate`, `vite`
- Runtime Modules:  `@nuxtjs/seo@2.0.0-rc.15`, `@nuxt/content@2.13.1`, `@nuxt/image@1.7.0`, `@nuxtjs/google-fonts@3.2.0`, `@nuxtjs/i18n@8.3.1`, `@nuxtjs/supabase@1.2.2`, `@pinia/nuxt@0.5.1`, `@vee-validate/nuxt@4.13.1`, `@vueuse/nuxt@10.11.0`, `@weareheavy/nuxt-cookie-consent@1.0.4`, `@zadigetvoltaire/nuxt-gtm@0.0.13`, `dayjs-nuxt@2.1.9`, `nuxt-icon@0.6.10`, `nuxt-lodash@2.5.3`, `nuxt-security@2.0.0-rc.9`, `nuxt-svgo@4.0.1`
- Build Modules:    `-`
harlan-zw commented 4 months ago

This is quite a strange bug, basically, the Nuxt Content integration is failing because the internal API call is failing for some reason.

I've pushed up some improvements so it can gracefully handle when these things fail instead of completely breaking.

You can try it out by deleting your lock file + node_modules and re-installing, this will use the latest nuxt robots version 4.0.2.

Let me know if you have any issues.

andrzejkupczyk commented 4 months ago

Works like a charm! Thank you so much for quickly looking into this, @harlan-zw. I didn’t find any issues anymore.
If you need my assistance in pinpointing the root cause on my end, just ping me.