File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -95,21 +95,25 @@ export const createTracingMixins = (options: TracingOptions): Mixins => {
95
95
96
96
this . $_sentrySpans = this . $_sentrySpans || { } ;
97
97
98
- // On the first handler call (before), it'll be undefined, as `$once` will add it in the future.
99
- // However, on the second call (after), it'll be already in place.
100
- const span = this . $_sentrySpans [ operation ] ;
101
-
102
- if ( span ) {
103
- span . finish ( ) ;
104
- finishRootSpan ( this , timestampInSeconds ( ) , options . timeout ) ;
105
- } else {
98
+ // Start a new span if current hook is a 'before' hook.
99
+ // Otherwise, retrieve the current span and finish it.
100
+ if ( internalHook == internalHooks [ 0 ] ) {
106
101
const activeTransaction = this . $root ?. $_sentryRootSpan || getActiveTransaction ( ) ;
107
102
if ( activeTransaction ) {
108
103
this . $_sentrySpans [ operation ] = activeTransaction . startChild ( {
109
104
description : `Vue <${ name } >` ,
110
105
op : `${ VUE_OP } .${ operation } ` ,
111
106
} ) ;
112
107
}
108
+ } else {
109
+ // The span should already be added via the first handler call (in the 'before' hook)
110
+ const span = this . $_sentrySpans [ operation ] ;
111
+ // The before hook did not start the tracking span, so the span was not added.
112
+ // This is probably because it happened before there is an active transaction
113
+ if ( ! span ) return ;
114
+
115
+ span . finish ( ) ;
116
+ finishRootSpan ( this , timestampInSeconds ( ) , options . timeout ) ;
113
117
}
114
118
} ;
115
119
}
You can’t perform that action at this time.
0 commit comments