File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
packages/nuxt/src/runtime/plugins Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -27,13 +27,23 @@ const SENTRY_ORIGIN = 'auto.db.nuxt';
2727 * Creates a Nitro plugin that instruments the database calls.
2828 */
2929export default defineNitroPlugin ( ( ) => {
30- const db = useDatabase ( ) ;
30+ try {
31+ debug . log ( '@sentry/nuxt: Instrumenting database...' ) ;
3132
32- debug . log ( '@sentry/nuxt: Instrumenting database...' ) ;
33+ const db = useDatabase ( ) ;
3334
34- instrumentDatabase ( db ) ;
35+ instrumentDatabase ( db ) ;
3536
36- debug . log ( '@sentry/nuxt: Database instrumented.' ) ;
37+ debug . log ( '@sentry/nuxt: Database instrumented.' ) ;
38+ } catch ( error ) {
39+ // During build time, we can't use the useDatabase function, so we just log an error.
40+ if ( error instanceof Error && / C a n n o t a c c e s s ' i n s t a n c e s ' / . test ( error . message ) ) {
41+ debug . log ( '@sentry/nuxt: Database instrumentation skipped during build time.' ) ;
42+ return ;
43+ }
44+
45+ debug . error ( '@sentry/nuxt: Failed to instrument database:' , error ) ;
46+ }
3747} ) ;
3848
3949function instrumentDatabase ( db : Database ) : void {
You can’t perform that action at this time.
0 commit comments