Commit cfd2d4f
fix(tracing): Recover app start data when first navigation transaction is discarded (#5833)
* fix(tracing): Recover app start data when first navigation transaction is discarded
When the first navigation idle transaction is discarded at spanEnd
(e.g., by ignoreEmptyRouteChangeTransactions because the navigation
container was registered too late), firstStartedActiveRootSpanId
remained permanently locked to the dead span. Since no transaction
event was ever created for it, processEvent never ran, and all
subsequent transactions failed the span ID check — silently losing
app start data for the entire session.
Add a spanEnd listener that resets the lock when the first root span
is unsampled at end time. Also set appStartEndData timestamp before
awaiting fetchNativeFrames to close a secondary timing race, and
improve failure recovery in attachAppStartToTransactionEvent.
Fixes #5831
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tracing): Add changelog entry for app start recovery fix
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tracing): Address review feedback for app start recovery
- Unsubscribe spanEnd listener after it fires to prevent listener leak
- Add _updateAppStartEndFrames helper instead of direct module-level mutation
- Make all processEvent failure paths set appStartDataFlushed = true
(these conditions won't change within the same app start, retrying is wasteful)
- Add comment about _sampled internal coupling in test
- Fix unnecessary type assertions (lint)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix(tracing): Check locked span sampled status at next spanStart instead of spanEnd
The spanEnd listener approach had a listener ordering bug: the app start
listener registered at spanStart time runs BEFORE the navigation discard
listeners (ignoreEmptyRouteChangeTransactions, ignoreEmptyBackNavigation)
that set _sampled = false. So our check always saw the span as sampled.
Instead, store a reference to the locked root span and check its sampled
status lazily at the next spanStart. By then, the old span has fully
completed and _sampled has been set to false by the discard listeners.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 11f4bd9 commit cfd2d4f
3 files changed
Lines changed: 185 additions & 8 deletions
File tree
- packages/core
- src/js/tracing/integrations
- test/tracing/integrations
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
87 | 93 | | |
88 | 94 | | |
89 | 95 | | |
90 | | - | |
| 96 | + | |
91 | 97 | | |
| 98 | + | |
92 | 99 | | |
93 | 100 | | |
94 | 101 | | |
95 | 102 | | |
96 | 103 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
| |||
133 | 135 | | |
134 | 136 | | |
135 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
136 | 151 | | |
137 | 152 | | |
138 | 153 | | |
| |||
184 | 199 | | |
185 | 200 | | |
186 | 201 | | |
| 202 | + | |
187 | 203 | | |
188 | 204 | | |
189 | 205 | | |
| |||
210 | 226 | | |
211 | 227 | | |
212 | 228 | | |
| 229 | + | |
213 | 230 | | |
214 | 231 | | |
215 | 232 | | |
| |||
235 | 252 | | |
236 | 253 | | |
237 | 254 | | |
238 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
239 | 270 | | |
240 | 271 | | |
241 | 272 | | |
| |||
246 | 277 | | |
247 | 278 | | |
248 | 279 | | |
| 280 | + | |
249 | 281 | | |
250 | 282 | | |
251 | 283 | | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
252 | 294 | | |
253 | 295 | | |
254 | 296 | | |
| |||
322 | 364 | | |
323 | 365 | | |
324 | 366 | | |
| 367 | + | |
325 | 368 | | |
326 | 369 | | |
327 | 370 | | |
| |||
347 | 390 | | |
348 | 391 | | |
349 | 392 | | |
| 393 | + | |
| 394 | + | |
350 | 395 | | |
351 | 396 | | |
352 | 397 | | |
| 398 | + | |
353 | 399 | | |
354 | 400 | | |
355 | 401 | | |
356 | 402 | | |
| 403 | + | |
357 | 404 | | |
358 | 405 | | |
359 | 406 | | |
360 | 407 | | |
361 | 408 | | |
362 | 409 | | |
| 410 | + | |
363 | 411 | | |
364 | 412 | | |
365 | 413 | | |
| |||
368 | 416 | | |
369 | 417 | | |
370 | 418 | | |
| 419 | + | |
371 | 420 | | |
372 | 421 | | |
373 | 422 | | |
374 | 423 | | |
375 | 424 | | |
376 | 425 | | |
377 | 426 | | |
| 427 | + | |
378 | 428 | | |
379 | 429 | | |
380 | 430 | | |
381 | 431 | | |
382 | 432 | | |
383 | 433 | | |
384 | 434 | | |
| 435 | + | |
385 | 436 | | |
386 | 437 | | |
387 | 438 | | |
| |||
393 | 444 | | |
394 | 445 | | |
395 | 446 | | |
| 447 | + | |
396 | 448 | | |
397 | 449 | | |
398 | 450 | | |
| |||
Lines changed: 124 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
467 | 520 | | |
468 | 521 | | |
469 | 522 | | |
| |||
894 | 947 | | |
895 | 948 | | |
896 | 949 | | |
| 950 | + | |
| 951 | + | |
| 952 | + | |
| 953 | + | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
| 1014 | + | |
| 1015 | + | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
897 | 1021 | | |
898 | 1022 | | |
899 | 1023 | | |
| |||
0 commit comments