mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-09-07 16:03:21 +00:00
Windows build broken by #[cfg] on tokio::select! branch (#9404)
#9400 (WIN-2003) added the ctrl_break() handler as a `#[cfg(windows)]` branch inside the two Windows-path `tokio::select!` blocks in shutdown_signal. tokio's `select!` macro does not accept `#[cfg(...)]` attributes on individual branches, so windmill-common fails to compile on Windows ("no rules expected this token in macro call"). This slipped through CI because the only job that builds the backend on Windows is cli-tests.yml's `test-windows`, which triggers only on `cli/**` changes — #9400 was backend-only. Fix: define `ctrl_break()` for the whole `not(any(linux, macos))` scope instead of just `windows`. On Windows it awaits the real CTRL_BREAK signal; on other non-unix targets it is a never-resolving future, so the branch is inert there. The select! branches become plain (no per-branch `#[cfg]`), which the macro accepts. Verified: the `#[cfg]`-on-branch form reproduces the exact macro error against tokio 1.46.1, and the fixed form compiles clean. Fixes WIN-2003 (Windows build regression) Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
e8ad53dae9
commit
d71d553ba4
@@ -282,10 +282,22 @@ pub async fn shutdown_signal(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
// Defined for the whole non-unix scope (not just windows) so it can be a
|
||||
// plain `tokio::select!` branch: that macro does not accept `#[cfg(...)]`
|
||||
// attributes on individual branches. On non-windows non-unix targets the
|
||||
// future never resolves, so the branch is effectively inert there.
|
||||
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
|
||||
async fn ctrl_break() -> std::io::Result<()> {
|
||||
tokio::signal::windows::ctrl_break()?.recv().await;
|
||||
Ok(())
|
||||
#[cfg(windows)]
|
||||
{
|
||||
tokio::signal::windows::ctrl_break()?.recv().await;
|
||||
Ok(())
|
||||
}
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
std::future::pending::<()>().await;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
@@ -306,7 +318,6 @@ pub async fn shutdown_signal(
|
||||
_ = tokio::signal::ctrl_c() => {
|
||||
tracing::info!("shutdown monitor received ctrl-c");
|
||||
},
|
||||
#[cfg(windows)]
|
||||
_ = ctrl_break() => {
|
||||
tracing::info!("shutdown monitor received ctrl-break");
|
||||
},
|
||||
@@ -331,7 +342,6 @@ pub async fn shutdown_signal(
|
||||
_ = tokio::signal::ctrl_c() => {
|
||||
tracing::error!("2nd shutdown monitor received ctrl-c")
|
||||
},
|
||||
#[cfg(windows)]
|
||||
_ = ctrl_break() => {
|
||||
tracing::error!("2nd shutdown monitor received ctrl-break")
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user