From 784fd58e9dfa0a5f62d917a14716109df5800775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Thu, 1 Aug 2024 21:50:18 +0200 Subject: [PATCH] docs: add debug recipe --- docs/content/1.docs/4.recipes/4.debug.md | 45 ++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 docs/content/1.docs/4.recipes/4.debug.md diff --git a/docs/content/1.docs/4.recipes/4.debug.md b/docs/content/1.docs/4.recipes/4.debug.md new file mode 100644 index 00000000..f498b67a --- /dev/null +++ b/docs/content/1.docs/4.recipes/4.debug.md @@ -0,0 +1,45 @@ +--- +navigation: + title: Debug Mode +title: Debug Mode (Boot) +description: Debug your Nuxt application when a boot error occurs on Cloudflare Workers. +--- + +Some Nuxt modules or librairies you use in your project may not be compatible with the edge runtime yet. When this happens, your Nuxt server cannot even start in production, producing a 500 error. + +The current solution to debug is the following. + +1. Disable Nitro minification in your `nuxt.config.ts` + +```ts [nuxt.config.ts] +export default defineNuxtConfig({ + nitro: { + minify: false + } +}) +``` + +2. Build your application for production with the Cloudflare Pages preset + +```bash [Terminal] +npx nuxt build --preset cloudflare-pages +``` + +3. Preview the production server in the Worker environment + +```bash [Terminal] +npx wrangler pages dev dist/ +``` + +::warning +As we don't support generating the `wrangler.toml` so far, you may expect some 500 errors when accessing the database, kv, cache or blob. +:: + +4. Open the browser by pressing the **b** shortut (most of the time it starts on ) +5. Go back to your terminal and look at the error and stack trace, then open the file (should be in the `dist/` directory) to know the line causing the error. + +::note +Most of the time, you will need to find scroll above to know what library is causing the error. +:: + +6. [Open an issue](https://github.com/nuxt-hub/core) in our repository so we can help making more librairies Edge compatible.