Skip to content

Conversation

alexander-alderman-webb
Copy link
Contributor

@alexander-alderman-webb alexander-alderman-webb commented Sep 5, 2025

Provide the option to record when an exception is set on a Future returned by ThreadPoolExecutor.submit(). These were previously thrown only when result() is called on the future. Otherwise the exception is only stored on the future, and does not detected by the ThreadingIntegration despite concurrent using threading under the hood.

Closes #2614

Copy link

codecov bot commented Sep 5, 2025

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
23729 1 23728 2305
View the top 1 failed test(s) by shortest run time
tests.profiler.test_continuous_profiler::test_continuous_profiler_auto_start_and_manual_stop[non-experiment-start_profiler/stop_profiler-gevent]
Stack Traces | 0.535s run time
tests/profiler/test_continuous_profiler.py:291: in test_continuous_profiler_auto_start_and_manual_stop
    assert_single_transaction_with_profile_chunks(envelopes, thread)
tests/profiler/test_continuous_profiler.py:147: in assert_single_transaction_with_profile_chunks
    assert len(items["profile_chunk"]) > 0
E   assert 0 > 0
E    +  where 0 = len([])

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review September 25, 2025 12:04
@alexander-alderman-webb alexander-alderman-webb requested a review from a team as a code owner September 25, 2025 12:04
client_options=sentry_sdk.get_client().options,
mechanism={"type": "concurrent", "handled": False},
)
sentry_sdk.capture_event(event, hint=hint)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Exception Callback Fails Context and Cancellation Handling

The report_exceptions callback doesn't use the isolation_scope and current_scope forked at submission time, so captured exception events lack proper context. Also, future.exception() can raise CancelledError if the future was cancelled, causing the callback to fail.

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems valid at first sight, I'll see if I can reproduce first-hand before changing

@alexander-alderman-webb alexander-alderman-webb marked this pull request as draft September 25, 2025 12:09
@alexander-alderman-webb
Copy link
Contributor Author

Need to revisit this to see if we want a dedicated FutureIntegration or to roll this into ThreadingIntegration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant