Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic when all chains are removed #1422

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 7 additions & 9 deletions light-base/src/network_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -978,16 +978,14 @@ async fn background_task<TPlat: PlatformRef>(mut task: BackgroundTask<TPlat>) {
.map_or(WakeUpReason::ForegroundClosed, WakeUpReason::Message)
};
let message_for_chain_received = async {
if !task.messages_rx.is_empty() {
let (chain_id, message) = task
.messages_rx
.next()
.await
.unwrap_or_else(|| unreachable!());
WakeUpReason::MessageForChain(chain_id, message)
} else {
// Note that when the last entry of `messages_rx` yields `None`, `messages_rx`
// itself will yield `None`. For this reason, we can't use
// `task.messages_rx.is_empty()` to determine whether `messages_rx` will
// yield `None`.
let Some((chain_id, message)) = task.messages_rx.next().await else {
future::pending().await
}
};
WakeUpReason::MessageForChain(chain_id, message)
};
let message_from_task_received = async {
let (connection_id, message) = task.tasks_messages_rx.next().await.unwrap();
Expand Down
4 changes: 4 additions & 0 deletions wasm-node/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Fixed

- Fix panic in network service when all chains are removed. ([#1422](https://github.com/smol-dot/smoldot/pull/1422))

## 2.0.11 - 2023-11-27

### Changed
Expand Down
Loading