Skip to content

Commit 171c8df

Browse files
committed
fix(nuxt): Ensure order of plugins is consistent
Noticed #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.
1 parent a75f456 commit 171c8df

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/nuxt/src/module.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export default defineNuxtModule<ModuleOptions>({
4242
addPluginTemplate({
4343
mode: 'client',
4444
filename: 'sentry-client-config.mjs',
45+
order: -20,
4546

4647
// Dynamic import of config file to wrap it within a Nuxt context (here: defineNuxtPlugin)
4748
// Makes it possible to call useRuntimeConfig() in the user-defined sentry config file
@@ -56,7 +57,13 @@ export default defineNuxtModule<ModuleOptions>({
5657
});`,
5758
});
5859

59-
addPlugin({ src: moduleDirResolver.resolve('./runtime/plugins/sentry.client'), mode: 'client' });
60+
// Add the plugin which loads client integrations etc. -
61+
// this must run after the sentry-client-config plugin has run, and the client is initialized!
62+
addPlugin({
63+
src: moduleDirResolver.resolve('./runtime/plugins/sentry.client'),
64+
mode: 'client',
65+
order: -10,
66+
});
6067
}
6168

6269
const serverConfigFile = findDefaultSdkInitFile('server', nuxt);

0 commit comments

Comments
 (0)