@@ -10,7 +10,6 @@ const errorPages = new Set(['/404', '/500', '/_error', '/_not-found', '/_not-fou
1010
1111class NextPlugin extends ServerPlugin {
1212 static id = 'next'
13- #requestsBySpanId = new WeakMap ( )
1413
1514 constructor ( ...args ) {
1615 super ( ...args )
@@ -35,11 +34,7 @@ class NextPlugin extends ServerPlugin {
3534
3635 analyticsSampler . sample ( span , this . config . measured , true )
3736
38- // Store request by span ID to handle cases where child spans are activated
39- const spanId = span . context ( ) . _spanId
40- this . #requestsBySpanId. set ( spanId , req )
41-
42- return { ...store , span }
37+ return { ...store , span, req }
4338 }
4439
4540 error ( { span, error } ) {
@@ -90,14 +85,7 @@ class NextPlugin extends ServerPlugin {
9085
9186 if ( ! store ) return
9287
93- const span = store . span
94-
95- const spanId = span . context ( ) . _spanId
96- const parentSpanId = span . context ( ) . _parentId
97-
98- // Try current span first, then parent span.
99- // This handles cases where pageLoad runs in a child span context
100- const req = this . #requestsBySpanId. get ( spanId ) ?? this . #requestsBySpanId. get ( parentSpanId )
88+ const { span, req } = store
10189
10290 // safeguard against missing req in complicated timeout scenarios
10391 if ( ! req ) return
0 commit comments