Skip to content

spawn_passive_check blocks main thread despite claiming background execution #36

@codesoda

Description

@codesoda

Summary

spawn_passive_check() in src/update.rs calls handle.join() which blocks the main thread indefinitely, despite its name and doc comment claiming it runs as a non-blocking background check that "abandons" the thread after 3 seconds.

Details

The current implementation:

pub fn spawn_passive_check() {
    let handle = std::thread::spawn(passive_version_check);
    let _ = handle.join(); // blocks indefinitely
}

The doc comment states:

Waits at most 3 seconds for the check to complete. If it doesn't finish, the thread is abandoned (it dies when the process exits).

However, std::thread::JoinHandle::join() has no timeout — it blocks the calling thread until the spawned thread terminates. The 3-second bound only holds because the HTTP client uses PASSIVE_CHECK_TIMEOUT (3s), but DNS resolution stalls or other pre-connection delays could cause longer blocks.

This runs on every successful bugatti test invocation (if code == EXIT_OK), adding up to 3+ seconds of exit delay.

Suggested fix

Either:

  • Fire-and-forget: Drop the join() entirely — let _ = std::thread::spawn(passive_version_check); and let the thread die when the process exits.
  • Timed wait: Use a channel with recv_timeout to implement an actual 3-second deadline.

Found during code review of #12.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions