Skip to content

socket length fixes#317

Merged
khaliqgant merged 4 commits intomainfrom
socket-handling
Jan 27, 2026
Merged

socket length fixes#317
khaliqgant merged 4 commits intomainfrom
socket-handling

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

@khaliqgant khaliqgant commented Jan 27, 2026

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 potential issue.

View issue and 5 additional flags in Devin Review.

Open in Devin Review

Comment thread packages/wrapper/src/relay-pty-orchestrator.ts Outdated
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View issue and 5 additional flags in Devin Review.

Open in Devin Review

Comment thread relay-pty/src/socket.rs
// Another process may have the socket - try removing again and retry
warn!("Socket address in use, attempting cleanup and retry: {}", self.socket_path);
let _ = std::fs::remove_file(path);
std::thread::sleep(std::time::Duration::from_millis(100));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Blocking std::thread::sleep used in async context

The retry logic for socket binding uses std::thread::sleep in an async function, which blocks the tokio runtime's worker thread.

Click to expand

Issue Details

In relay-pty/src/socket.rs:100, the code uses std::thread::sleep(std::time::Duration::from_millis(100)) inside the async fn run() method:

Err(e) if e.kind() == std::io::ErrorKind::AddrInUse => {
    warn!("Socket address in use, attempting cleanup and retry: {}", self.socket_path);
    let _ = std::fs::remove_file(path);
    std::thread::sleep(std::time::Duration::from_millis(100));  // Blocks tokio worker!
    UnixListener::bind(&self.socket_path)
        .context(format!("Failed to bind socket at {} (after retry)", self.socket_path))?
}

This function is spawned via tokio::spawn in main.rs:310, meaning std::thread::sleep will block the tokio worker thread instead of yielding to other tasks.

Impact

During the 100ms sleep, other async tasks scheduled on the same worker thread will be blocked. Since this only occurs during startup in the rare EADDRINUSE retry path, the practical impact is minimal.

Expected Behavior

Use tokio::time::sleep(Duration::from_millis(100)).await for non-blocking sleep in async context.

Recommendation: Replace std::thread::sleep(std::time::Duration::from_millis(100)) with tokio::time::sleep(std::time::Duration::from_millis(100)).await

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

khaliqgant and others added 2 commits January 27, 2026 01:18
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@khaliqgant khaliqgant merged commit 285a451 into main Jan 27, 2026
30 checks passed
@khaliqgant khaliqgant deleted the socket-handling branch January 27, 2026 00:31
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