smol-rs / event-listener

Notify async tasks or threads
Apache License 2.0
449 stars 30 forks source link

Loosen concurrent-queue dependency #142

Closed CodingAnarchy closed 5 months ago

CodingAnarchy commented 5 months ago

We ran into an issue with this transitive dependency because event-listener requires 2.4.0 for concurrent-queue, but when we added async-channel as another transitive dependency (which depends on 2.5), Cargo resolved the wrong version when compiling the async-channel dependency.

error[E0432]: unresolved import `concurrent_queue::ForcePushError`
  --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-channel-2.3.0/src/lib.rs:50:41
   |
50 | use concurrent_queue::{ConcurrentQueue, ForcePushError, PopError, PushError};
   |                                         ^^^^^^^^^^^^^^ no `ForcePushError` in the root

error[E0599]: no method named `force_push` found for struct `ConcurrentQueue` in the current scope
   --> ~/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-channel-2.3.0/src/lib.rs:313:34
    |
313 |         match self.channel.queue.force_push(msg) {
    |                                  ^^^^^^^^^^ method not found in `ConcurrentQueue<T>`

Some errors have detailed explanations: E0432, E0599.
For more information about an error, try `rustc --explain E0432`.
error: could not compile `async-channel` (lib) due to 2 previous errors

We managed to work around this by explciitly specifying concurrent-queue = "2.5" in our Cargo.toml file directly, but it would also help if the dependency here was less strict and allowed for 2.x versions. I know that #109 proposes removing that dependency entirely (which would be fantastic), but if a looser dependency check makes sense, I can open a much quicker PR to accomplish that.

notgull commented 5 months ago

The current dependency is:

concurrent-queue = { version = "2.4.0", default-features = false }

This should allow for v2.5 as well. Could you consider investigating your Cargo.lock file?

CodingAnarchy commented 5 months ago

I've looked into this more, and it seems like the issue was that async-channel itself was set with an incompatible version requirement, so the fact that 2.4.0 was already in the lock file meant no upgrade was done.

They fixed this in a patch release so we just upgraded there. Apologies for the noise.