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 => {
9595
9696 this . $_sentrySpans = this . $_sentrySpans || { } ;
9797
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 ] ) {
106101 const activeTransaction = this . $root ?. $_sentryRootSpan || getActiveTransaction ( ) ;
107102 if ( activeTransaction ) {
108103 this . $_sentrySpans [ operation ] = activeTransaction . startChild ( {
109104 description : `Vue <${ name } >` ,
110105 op : `${ VUE_OP } .${ operation } ` ,
111106 } ) ;
112107 }
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 ) ;
113117 }
114118 } ;
115119 }
You can’t perform that action at this time.
0 commit comments