Skip to content

refactor(sinktools): use pin_project in LazySinkSource#2579

Draft
MingweiSamuel wants to merge 3 commits intomainfrom
lazy-2
Draft

refactor(sinktools): use pin_project in LazySinkSource#2579
MingweiSamuel wants to merge 3 commits intomainfrom
lazy-2

Conversation

@MingweiSamuel
Copy link
Member

@MingweiSamuel MingweiSamuel commented Feb 13, 2026

Stack: #2556

Kiro-generated, requires close review

Copilot AI review requested due to automatic review settings February 13, 2026 00:16
@MingweiSamuel MingweiSamuel marked this pull request as draft February 13, 2026 00:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors sinktools::LazySinkSource to use pin_project with an internal pinned state machine and replaces the previous multi-waker approach with a dual AtomicWaker setup, while updating/expanding async unit tests around initialization driving.

Changes:

  • Refactor LazySinkSource to a pinned SharedState enum using pin_project_lite (removing the old Rc<RefCell<...>> split-halves implementation).
  • Replace MultiWaker (mutex + vec) with DualWaker using two AtomicWakers (sink vs stream) and a shared wake fanout.
  • Update tests and add Tokio time dev-dependency feature to support timing-based assertions.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
sinktools/src/lazy_sink_source.rs Reworks internal state/pinning and waker handling; updates and adds tests validating sink/stream-driven initialization.
sinktools/Cargo.toml Enables Tokio time feature for dev-dependencies to support updated tests.
Comments suppressed due to low confidence (1)

sinktools/src/lazy_sink_source.rs:229

  • poll_next returns Poll::Ready(None) when the initialization future resolves to Err, but it leaves the state in Thunkulating. If the stream is polled again after yielding None (which Stream contract allows), this will re-poll a completed future and may panic or otherwise violate the expectation that the stream remains terminated. Consider transitioning to a terminal state on init failure (e.g., an InitFailed/Terminated variant) so subsequent poll_next calls reliably return Ready(None) without polling the init future again.
                Poll::Ready(Err(_)) => {
                    return Poll::Ready(None);
                }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +451 to 452
tokio::time::sleep(std::time::Duration::from_millis(10)).await;

Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

This test now relies on a fixed wall-clock sleep (sleep(Duration::from_millis(10))) to wait for task wakeups/propagation, which can be flaky under slow or loaded CI runners (and unnecessarily slows fast runs). Prefer an event-driven wait (e.g., loop with yield_now() until the condition is true with an overall timeout, or a oneshot/Notify that signals when initialization completes) so the test is deterministic.

Copilot uses AI. Check for mistakes.
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 13, 2026

Deploying hydro with  Cloudflare Pages  Cloudflare Pages

Latest commit: 74e307b
Status: ✅  Deploy successful!
Preview URL: https://2499bde7.hydroflow.pages.dev
Branch Preview URL: https://lazy-2.hydroflow.pages.dev

View logs

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