Skip to content

feat(core): Stream extension trait - #1214

Open
lcian wants to merge 11 commits into
masterfrom
lcian/feat/stream-ext
Open

feat(core): Stream extension trait#1214
lcian wants to merge 11 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.

@szokeasaurusrex

Copy link
Copy Markdown
Member

@lcian what is the status with this PR? Is it abandoned or are you still planning to finish it and get it ready for review?

@lcian
lcian marked this pull request as ready for review August 3, 2026 11:12
@lcian
lcian requested a review from a team as a code owner August 3, 2026 11:12
@lcian

lcian commented Aug 3, 2026

Copy link
Copy Markdown
Member Author

@szokeasaurusrex it's ready for review now, please take a look whenever you have time. I don't need this at the moment but it came up a couple times, so I think it would be a nice utility to have.

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.

2 participants