Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions crates/adapters/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,11 @@ impl Controller {
let _ = init_status_sender.send(Err(error));
Ok(())
}
Ok(circuit_thread) => {
circuit_thread.run(init_status_sender).inspect_err(|error| {
Ok(mut circuit_thread) => {
if let Err(error) = circuit_thread.run(init_status_sender) {
circuit_thread.controller.error(error, None);
}
circuit_thread.finish().inspect_err(|error| {
// Log the error before returning it from the
// thread: otherwise, only [Controller::stop]
// will join the thread and report the error.
Comment on lines +554 to 561
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

The error returned from circuit_thread.run is now consumed by error() and never propagated as the thread’s Result, so callers joining the thread will only see errors from finish() (if any), which differs from the prior behavior and contradicts the nearby comment about “returning it from the thread.” Consider preserving the original contract by also reflecting the run error in the returned Result (for example, by returning that error when run fails, or by combining run/finish errors in a way that ensures joiners still observe the failure).

Copilot uses AI. Check for mistakes.
Expand Down Expand Up @@ -2276,7 +2279,7 @@ impl CircuitThread {
/// * `init_status_sender` - A channel sender to report the result of the initialization.
/// The circuit is considered fully initialized after executing the first step.
fn run(
mut self,
&mut self,
init_status_sender: SyncSender<Result<Arc<ControllerInner>, ControllerError>>,
) -> Result<(), ControllerError> {
let config = &self.controller.status.pipeline_config;
Expand Down Expand Up @@ -2324,7 +2327,7 @@ impl CircuitThread {
}

if self.controller.state() == PipelineState::Terminated {
break;
break Ok(());
}

// Backpressure in the output pipeline: wait for room in output buffers to
Expand Down Expand Up @@ -2357,7 +2360,7 @@ impl CircuitThread {
) {
Action::Step => {
if !self.step()? {
break;
break Ok(());
}
}
Action::Checkpoint => self.checkpoint_requests.push(CheckpointRequest::Scheduled),
Expand All @@ -2368,6 +2371,9 @@ impl CircuitThread {
Action::Park(None) => self.parker.park(),
}
}
}

fn finish(mut self) -> Result<(), ControllerError> {
self.controller.status.set_state(PipelineState::Terminated);
self.flush_commands_and_requests();
self.circuit
Expand Down Expand Up @@ -5679,8 +5685,8 @@ impl ControllerInner {
}
}

fn error(&self, error: Arc<ControllerError>, tag: Option<String>) {
(self.error_cb)(error, tag);
fn error(&self, error: impl Into<Arc<ControllerError>>, tag: Option<String>) {
(self.error_cb)(error.into(), tag);
}

/// Process an input transport error.
Expand Down
Loading