Skip to content

Commit 44714a9

Browse files
gui1117github-actions[bot]bkchr
committed
substrate-prometheus-endpoint: directly require the feature "tokio/net" (#9355)
The crate `substrate-prometheus-endpoint` use tokio items given by the feature "net" but it doesn't explictly requires it in the `Cargo.toml`. It compiles on master because `hyper-util` enables the feature "tokio/net". But upgrading `hyper-util` break this indirect enabling. This fix the issue by directly setting "net" feature as required, as it is used. We should also backport this ideally. It is not a breaking change given the code doesn't compile without the feature and only compiles if indirectly enabled by another crate. # Reproduce: To reproduce do `cargo update -p hyper-util && cargo check -p substrate-prometheus-endpoint`: You will get the error: ``` error[E0433]: failed to resolve: could not find `TcpListener` in `net` --> substrate/utils/prometheus/src/lib.rs:89:29 | 89 | let listener = tokio::net::TcpListener::bind(&prometheus_addr).await.map_err(|e| { | ^^^^^^^^^^^ could not find `TcpListener` in `net` | note: found an item that was configured out --> /home/gui/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.45.0/src/net/mod.rs:43:28 | 43 | pub use tcp::listener::TcpListener; | ^^^^^^^^^^^ note: the item is gated behind the `net` feature --> /home/gui/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.45.0/src/net/mod.rs:38:1 | 38 | / cfg_net! { 39 | | mod lookup_host; 40 | | pub use lookup_host::lookup_host; ... | 51 | | } 52 | | } | |_^ = note: this error originates in the macro `cfg_net` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing this struct | 20 + use std::net::TcpListener; | help: if you import `TcpListener`, refer to it directly | 89 - let listener = tokio::net::TcpListener::bind(&prometheus_addr).await.map_err(|e| { 89 + let listener = TcpListener::bind(&prometheus_addr).await.map_err(|e| { | error[E0412]: cannot find type `TcpListener` in module `tokio::net` --> substrate/utils/prometheus/src/lib.rs:99:24 | 99 | listener: tokio::net::TcpListener, | ^^^^^^^^^^^ not found in `tokio::net` | note: found an item that was configured out --> /home/gui/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.45.0/src/net/mod.rs:43:28 | 43 | pub use tcp::listener::TcpListener; | ^^^^^^^^^^^ note: the item is gated behind the `net` feature --> /home/gui/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.45.0/src/net/mod.rs:38:1 | 38 | / cfg_net! { 39 | | mod lookup_host; 40 | | pub use lookup_host::lookup_host; ... | 51 | | } 52 | | } | |_^ = note: this error originates in the macro `cfg_net` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing this struct | 20 + use std::net::TcpListener; | help: if you import `TcpListener`, refer to it directly | 99 - listener: tokio::net::TcpListener, 99 + listener: TcpListener, | Some errors have detailed explanations: E0412, E0433. For more information about an error, try `rustc --explain E0412`. error: could not compile `substrate-prometheus-endpoint` (lib) due to 2 previous errors ``` --------- Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Bastian Köcher <[email protected]> (cherry picked from commit fb451c7)
1 parent d4a1adc commit 44714a9

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

prdoc/pr_9355.prdoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
title: 'substrate-prometheus-endpoint: directly require the feature "tokio/net"'
2+
doc:
3+
- audience: Node Dev
4+
description: |-
5+
The crate `substrate-prometheus-endpoint` use tokio items given by the feature "net" but it doesn't explictly requires it in the `Cargo.toml`. It compiles on master because `hyper-util` enables the feature "tokio/net". But upgrading `hyper-util` break this indirect enabling.
6+
7+
This fix the issue by directly setting "net" feature as required, as it is used.
8+
We should also backport this ideally. It is not a breaking change given the code doesn't compile without the feature and only compiles if indirectly enabled by another crate.
9+
crates:
10+
- name: substrate-prometheus-endpoint
11+
bump: patch

substrate/utils/prometheus/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ hyper-util = { features = ["server-auto", "server-graceful", "tokio"], workspace
2222
log = { workspace = true, default-features = true }
2323
prometheus = { workspace = true }
2424
thiserror = { workspace = true }
25-
tokio = { features = ["parking_lot"], workspace = true, default-features = true }
25+
tokio = { features = ["net", "parking_lot"], workspace = true, default-features = true }
2626

2727
[dev-dependencies]
2828
hyper-util = { features = ["client-legacy", "tokio"], workspace = true, default-features = true }

0 commit comments

Comments
 (0)