From 171c8dff5ab2d834845d84a7a3085876ab2ff42f Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Thu, 3 Jul 2025 10:41:19 +0200 Subject: [PATCH 1/2] fix(nuxt): Ensure order of plugins is consistent Noticed https://github.com/getsentry/sentry-javascript/pull/16783 in the nuxt-3-min test, that the plugins are not consistently run apparently. In that test, the client integrations plugin was run before the client config plugin, leading to the client not existing yet, and thus not adding the browser tracing integration. This PR changes this to ensure we have a consistent order of these plugins. --- packages/nuxt/src/module.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/nuxt/src/module.ts b/packages/nuxt/src/module.ts index bb9843bd6ce2..aad2df4ed0c4 100644 --- a/packages/nuxt/src/module.ts +++ b/packages/nuxt/src/module.ts @@ -42,6 +42,7 @@ export default defineNuxtModule({ addPluginTemplate({ mode: 'client', filename: 'sentry-client-config.mjs', + order: -20, // Dynamic import of config file to wrap it within a Nuxt context (here: defineNuxtPlugin) // Makes it possible to call useRuntimeConfig() in the user-defined sentry config file @@ -56,7 +57,13 @@ export default defineNuxtModule({ });`, }); - addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/sentry.client'), mode: 'client' }); + // Add the plugin which loads client integrations etc. - + // this must run after the sentry-client-config plugin has run, and the client is initialized! + addPlugin({ + src: moduleDirResolver.resolve('./runtime/plugins/sentry.client'), + mode: 'client', + order: -10, + }); } const serverConfigFile = findDefaultSdkInitFile('server', nuxt); From 9fedd691df113fcfb4476af9fce714fb377db540 Mon Sep 17 00:00:00 2001 From: Francesco Novy Date: Thu, 3 Jul 2025 14:14:59 +0200 Subject: [PATCH 2/2] better order --- packages/nuxt/src/module.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/nuxt/src/module.ts b/packages/nuxt/src/module.ts index aad2df4ed0c4..5392774d330d 100644 --- a/packages/nuxt/src/module.ts +++ b/packages/nuxt/src/module.ts @@ -42,7 +42,7 @@ export default defineNuxtModule({ addPluginTemplate({ mode: 'client', filename: 'sentry-client-config.mjs', - order: -20, + order: 0, // Dynamic import of config file to wrap it within a Nuxt context (here: defineNuxtPlugin) // Makes it possible to call useRuntimeConfig() in the user-defined sentry config file @@ -62,7 +62,7 @@ export default defineNuxtModule({ addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/sentry.client'), mode: 'client', - order: -10, + order: 1, }); }