Commit 72bf32d
fix(react): Remove unused
## Summary
Removes the `react.componentStack` event context set by
`captureReactException`.
The shipped string never has sourcemaps applied, so it's mostly
unreadable in the Sentry UI. For React >= 17 the same component stack is
already attached via `error.cause` (which *does* get sourcemaps); for
React < 17 it offers little value either. Maintainer-confirmed in
#20094.
## Root cause
`captureReactException` wrapped the capture in `withScope` solely to
attach the `react.componentStack` context. With that context gone the
`withScope` wrapper has no other mutation, so it collapses to a direct
`captureException` call (and `withScope` drops out of the imports).
Test sync: `scopeSetContextSpy` in `errorboundary.test.tsx` is removed.
The two
`expect(cause.stack).toEqual(scopeSetContextSpy.mock.calls[...])`
assertions become `expect.any(String)` — the strongest invariant left
now that the spy is gone, since the underlying `setCause` /
`errorBoundaryError.stack = componentStack` chain is unchanged. The
recursive-cause negation collapses into the existing `cause.name`
assertion, with an inline comment explaining why the original cause is
preserved when the chain loops.
Fixes #20094
---------
Co-authored-by: zhongrenfei1-hub <231221504+zhongrenfei1-hub@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: Nicolas Hrubec <nico.hrubec@sentry.io>react.componentStack event context (#21183)1 parent 6480127 commit 72bf32d
2 files changed
Lines changed: 8 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
| 67 | + | |
71 | 68 | | |
72 | 69 | | |
73 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
| |||
221 | 220 | | |
222 | 221 | | |
223 | 222 | | |
224 | | - | |
225 | 223 | | |
226 | 224 | | |
227 | 225 | | |
| |||
388 | 386 | | |
389 | 387 | | |
390 | 388 | | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | 389 | | |
395 | 390 | | |
396 | 391 | | |
397 | 392 | | |
398 | 393 | | |
399 | 394 | | |
400 | | - | |
| 395 | + | |
401 | 396 | | |
402 | 397 | | |
403 | 398 | | |
| |||
447 | 442 | | |
448 | 443 | | |
449 | 444 | | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | 445 | | |
454 | 446 | | |
455 | 447 | | |
| |||
486 | 478 | | |
487 | 479 | | |
488 | 480 | | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | 481 | | |
493 | 482 | | |
494 | 483 | | |
495 | 484 | | |
496 | 485 | | |
497 | 486 | | |
498 | | - | |
| 487 | + | |
499 | 488 | | |
500 | 489 | | |
501 | 490 | | |
| |||
530 | 519 | | |
531 | 520 | | |
532 | 521 | | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | 522 | | |
537 | 523 | | |
538 | 524 | | |
539 | 525 | | |
540 | | - | |
541 | | - | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
542 | 530 | | |
543 | 531 | | |
544 | 532 | | |
| |||
697 | 685 | | |
698 | 686 | | |
699 | 687 | | |
700 | | - | |
701 | | - | |
702 | | - | |
703 | 688 | | |
704 | 689 | | |
705 | 690 | | |
| |||
0 commit comments