Skip to content

Commit

Permalink
[net:poll] Add log line when the reactor wakes up without commands (#136
Browse files Browse the repository at this point in the history
)

This commit removes the debug assert since it occurs a few times.

Therefore, the debug assert is replaced with a warning log
line, allowing us to track the frequency of this occurrence.

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
  • Loading branch information
vincenzopalazzo committed Mar 1, 2024
1 parent 9ea71ed commit 29bdf44
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions net/poll/src/reactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,12 @@ impl<Id: PeerId> nakamoto_net::Reactor<Id> for Reactor<net::TcpStream, Id> {
}
popol::Waker::reset(ev.source).ok();

// Nb. This assert has triggered once, but I wasn't available
// to reproduce it.
debug_assert!(!commands.is_empty());
// Nb. This should not happen, but it has been reported
// a few times. So we try to log a warning message and
// see how often this occurs.
if commands.is_empty() {
log::warn!(target: "poll", "waken up by waker received without commands");
}

for cmd in commands.try_iter() {
service.command_received(cmd);
Expand Down

1 comment on commit 29bdf44

@samrock5000
Copy link

Choose a reason for hiding this comment

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

I been running into this while using:
https://crates.io/crates/nakamoto-net-poll
https://docs.rs/nakamoto-net-poll/0.4.0/src/nakamoto_net_poll/reactor.rs.html#258

i made a reproduction while trying to make a UI in tauri:

https://github.com/samrock5000/nakamoto-ui

It seems if you queu up commands before the node is fully initialized the assertion hits.

Please sign in to comment.