Skip to content

Commit 335e9a3

Browse files
add explanation comments
1 parent 309e6ef commit 335e9a3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

sentry_sdk/utils.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,10 +741,18 @@ def single_exception_from_error_tuple(
741741
max_value_length=max_value_length,
742742
custom_repr=custom_repr,
743743
)
744+
# Process at most MAX_STACK_FRAMES + 1 frames, to avoid hanging on
745+
# processing a super-long stacktrace.
744746
for tb, _ in zip(iter_stacks(tb), range(MAX_STACK_FRAMES + 1))
745747
] # type: List[Dict[str, Any]]
746748

747749
if len(frames) > MAX_STACK_FRAMES:
750+
# If we have more frames than the limit, we remove the stacktrace completely.
751+
# We don't trim the stacktrace here because we have not processed the whole
752+
# thing (see above, we stop at MAX_STACK_FRAMES + 1). Normally, Relay would
753+
# intelligently trim by removing frames in the middle of the stacktrace, but
754+
# since we don't have the whole stacktrace, we can't do that. Instead, we
755+
# drop the entire stacktrace.
748756
exception_value["stacktrace"] = AnnotatedValue.removed_because_over_size_limit(
749757
value=None
750758
)

0 commit comments

Comments
 (0)