SDK stuck in processing RecursionError:maximum recursion depth exceeded events #2764
Description
How do you use Sentry?
Sentry Saas (sentry.io)
Version
1.40.5
Steps to Reproduce
One Sentry user reported an issue where the SDK gets in am apparently endless loop while processing a RecursionError.
I was able to reproduce it with a simple FastAPI project and setting recursion depth limit to 1M:
import resource, sys
sys.setrecursionlimit(10**6)
from fastapi import FastAPI
import logging
from sentry_sdk.integrations.fastapi import FastApiIntegration
import sentry_sdk
sentry_sdk.init(
dsn="....",
debug=True,
)
def fibonacci_of(n):
return fibonacci_of(n)
app = FastAPI()
@app.get("/")
fibonacci_of(50)
return {"OH dear"}
The code above creates an infinite recursion, which will eventually trigger a RecursionError:maximum recursion depth exceeded events
error that is captured by the SDK.
In a sync environment the SDK will hold the app while processing the event. I suspect it is during stack trace processing, as in this case the stack trace will have 1M frames.
Original report can be found in this internal ticket.
Expected Result
The SDK is able to quickly process the event and attempt to send it, or stop processing in case it takes long freeing the app.
Actual Result
The SDK gets in an seemingly infinite loop.
Metadata
Assignees
Type
Projects
Status
No status
Status
No status