Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions prdoc/pr_9355.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
title: 'substrate-prometheus-endpoint: directly require the feature "tokio/net"'
doc:
- audience: Node Dev
description: |-
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
```
crates:
- name: substrate-prometheus-endpoint
bump: patch
2 changes: 1 addition & 1 deletion substrate/utils/prometheus/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ hyper-util = { features = ["server-auto", "server-graceful", "tokio"], workspace
log = { workspace = true, default-features = true }
prometheus = { workspace = true }
thiserror = { workspace = true }
tokio = { features = ["parking_lot"], workspace = true, default-features = true }
tokio = { features = ["net", "parking_lot"], workspace = true, default-features = true }

[dev-dependencies]
hyper-util = { features = ["client-legacy", "tokio"], workspace = true, default-features = true }
Expand Down
Loading