Skip to content

feat(core): Stream extension trait#1214

Draft
lcian wants to merge 7 commits into
masterfrom
lcian/feat/stream-ext
Draft

feat(core): Stream extension trait#1214
lcian wants to merge 7 commits into
masterfrom
lcian/feat/stream-ext

Conversation

@lcian

@lcian lcian commented Jun 30, 2026

Copy link
Copy Markdown
Member

Description

This adds an extension trait for futures_core::Stream that can be used to .bind_hub(...) on a stream, much like the existing machinery we have for futures.
This came up a few times already, and it happens to be one of the ways one could work around #1208 (given that the problematic response body is a stream, one can use such a stream wrapper to bind the current hub before converting that stream to a response -- I still think a proper separate fix should be introduced in the sentry-tower instrumentation though, as the user should not have to remember to do this manually. This is a more general construct that can be used in other scenarios too.

@github-actions

This comment has been minimized.

@lcian lcian changed the title lcian/feat/stream ext feat: Stream extension Jun 30, 2026
@lcian lcian changed the title feat: Stream extension feat(core): Stream extension trait Jun 30, 2026
Comment thread sentry-core/src/stream.rs
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
let hub = self.hub.clone();
// https://doc.rust-lang.org/std/pin/index.html#pinning-is-structural-for-field
let stream = unsafe { self.map_unchecked_mut(|s| &mut s.stream) };

@lcian lcian Jun 30, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It is possible to avoid this direct usage of unsafe (and the one in SentryFuture) by adding a dependency to pin-project-lite.

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