Skip to content

fix(backend): increase default ping timeout - #207

Merged
zouyonghe merged 2 commits into
AstrBotDevs:mainfrom
zouyonghe:codex/backend-ping-timeout-5000
Dec 3, 2026
Merged

zouyonghe merged 2 commits into
AstrBotDevs:mainfrom
zouyonghe:codex/backend-ping-timeout-5000

Conversation

@zouyonghe

@zouyonghe zouyonghe commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Fixes #203.

Problem

The managed-backend start preflight added in #191 uses ASTRBOT_BACKEND_PING_TIMEOUT_MS to confirm that the configured endpoint is free. Its default is 800 ms. On Windows, a connection to a closed loopback port can take about two seconds to report refusal, so the preflight times out as inconclusive and blocks the backend spawn. The reported ASTRBOT_BACKEND_PING_TIMEOUT_MS=5000 override allows startup.

Change

  • Increase the default backend ping timeout from 800 ms to 5000 ms.
  • Keep existing environment overrides and timeout bounds unchanged.
  • Update the environment-variable documentation and add a regression test for the default.

PR #204 is also open for this startup failure. It uses a probe-specific 3000 ms minimum, while this change follows the reported 5000 ms override by increasing the shared default.

Validation

  • cargo fmt --manifest-path src-tauri/Cargo.toml --all -- --check
  • cargo clippy --manifest-path src-tauri/Cargo.toml --locked --all-targets -- -D warnings
  • cargo check --manifest-path src-tauri/Cargo.toml --locked
  • cargo test --manifest-path src-tauri/Cargo.toml --locked -- --nocapture — 288 passed on macOS.

Native Windows runtime verification was not available in this environment.

Summary by Sourcery

Allow managed backends more time to respond to the startup availability check.

Bug Fixes:

  • Increase the default backend ping timeout to five seconds so slower connection-refusal responses are less likely to block managed-backend startup.
  • Ensure the configured ping timeout is shared across address connection attempts instead of applying the full timeout separately to each address.

Documentation:

  • Update the environment-variable documentation to show the new five-second default; the allowed range and override behavior remain unchanged.

Tests:

  • Add a regression test asserting the five-second default backend ping timeout.

@sourcery-ai

sourcery-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit 173b1c3

#203 [Bug] 更新4.30.0桌面版无法打开 · 0 of 1 met · 1 to check by hand

# Requirement Status Notes
1 正常打开(更新后桌面版能够启动) 👀 Check by hand (runtime) Verify on Windows that the launcher starts normally after updating from 4.29.4 to 4.30.0 with the default timeout; native Windows runtime verification was unavailable.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 1 issue

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src-tauri/src/app_constants.rs" line_range="40" />
<code_context>
 pub(crate) const DEFAULT_BACKEND_STARTUP_HEARTBEAT_RELATIVE_PATH: &str =
     "data/backend-startup-heartbeat.json";
-pub(crate) const DEFAULT_BACKEND_PING_TIMEOUT_MS: u64 = 800;
+pub(crate) const DEFAULT_BACKEND_PING_TIMEOUT_MS: u64 = 5_000;
 pub(crate) const BACKEND_PING_TIMEOUT_MIN_MS: u64 = 50;
 pub(crate) const BACKEND_PING_TIMEOUT_MAX_MS: u64 = 30_000;
</code_context>
<issue_to_address>
**Multi-address probes exceed timeout**

When `ASTRBOT_BACKEND_URL` resolves to multiple addresses and earlier addresses take their full connect timeout to fail, `ping_backend` applies the timeout separately to each resolved address, so unreachable addresses can consume five seconds apiece before it reaches a later working address or returns false; managed-backend startup is delayed well beyond the documented ping timeout.

Use one deadline for the whole address probe and pass each connection attempt only the remaining time.
</issue_to_address>

Sourcery assessment

Approval pending. 1 finding to address first.

Blocking findings: src-tauri/src/app_constants.rs:40


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread src-tauri/src/app_constants.rs Resolved

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sourcery assessment

Approved.

@zouyonghe
zouyonghe merged commit 615f499 into AstrBotDevs:main Dec 3, 2026
4 checks passed
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.

[Bug] 更新4.30.0桌面版无法打开

1 participant