Skip to content

thomasttvo/sentry-recursion-repro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Sentry Event Processor Infinite Recursion Repro

This repo demonstrates an infinite recursion bug in @sentry/react-native (and likely all Sentry SDKs) when an event processor throws an error.

The Bug

When an event processor throws an error:

  1. Sentry's internal error handler catches it
  2. It calls captureException() to report the processor error
  3. captureException() runs through the same event processors
  4. The processor throws again → goto step 1
  5. Infinite loop until the app crashes or becomes unresponsive

Reproduction

  1. Install dependencies:

    npm install
  2. Start the app:

    npx expo start
  3. Press "Trigger captureMessage" button

  4. Watch the console - you'll see EVENT PROCESSOR CALLED: N incrementing rapidly

  5. Press "Update count" to see how many times the processor was called (likely thousands before the app becomes unresponsive)

Expected Behavior

Sentry should detect the recursion and break the loop, e.g., by:

  • Tracking if we're already handling a processor error
  • Skipping event processors for error events about processor failures
  • Limiting the recursion depth

Actual Behavior

The event processor is called 300+ times in seconds (limited only by memory/stack exhaustion). In our real app testing, we've seen 8700+ calls before force-termination.

Impact

  1. Infinite async loop - consumes resources continuously (doesn't freeze UI since it's async)
  2. Original event is lost - the initial message/exception is never sent to Sentry
  3. Thousands of error events queued - floods the event queue
  4. HMR breaks - in React Native dev mode, this breaks Hot Module Replacement

Environment

  • @sentry/react-native: 7.11.0 (latest)
  • Expo SDK: 54
  • React Native: (via Expo)

Related Issues

  • #2716 - Sentry acknowledged "it'd cause an infinite loop" but closed without fix
  • #2148 - addEventProcessor silently drops exceptions

About

Minimal repro for Sentry event processor infinite recursion bug

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors