Skip to content

Errors handling ShardRunnerMessage shut down shards #3347

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

Open
DPlayer234 opened this issue Apr 15, 2025 · 0 comments
Open

Errors handling ShardRunnerMessage shut down shards #3347

DPlayer234 opened this issue Apr 15, 2025 · 0 comments
Labels
bug Something misbehaves or is not working. gateway Related to the `gateway` module.

Comments

@DPlayer234
Copy link
Contributor

On next, when handling ShardRunnerMessage variants that send messages to the websocket, encountering an error will shut down the shard without logging any sort of warning or error. The shard is not queued to be restarted in that case either:

// Handles a received value over the shard runner rx channel.
//
// Returns a boolean on whether the shard runner can continue.
//
// This always returns true, except in the case that the shard manager asked the runner to
// shutdown or restart.
#[cfg_attr(feature = "tracing_instrument", instrument(skip(self)))]
async fn handle_rx_value(&mut self, msg: ShardRunnerMessage) -> bool {
match msg {
ShardRunnerMessage::Restart => {
self.restart().await;
false
},
ShardRunnerMessage::Shutdown(code) => {
self.shutdown(code).await;
false
},
ShardRunnerMessage::ChunkGuild {
guild_id,
limit,
presences,
filter,
nonce,
} => self
.shard
.chunk_guild(guild_id, limit, presences, filter, nonce.as_deref())
.await
.is_ok(),
ShardRunnerMessage::SetPresence {
activity,
status,
} => {
if let Some(activity) = activity {
self.shard.set_activity(activity);
}
if let Some(status) = status {
self.shard.set_status(status);
}
self.shard.update_presence().await.is_ok()
},
#[cfg(feature = "voice")]
ShardRunnerMessage::UpdateVoiceState {
guild_id,
channel_id,
self_mute,
self_deaf,
} => self
.shard
.update_voice_state(guild_id, channel_id, self_mute, self_deaf)
.await
.is_ok(),
}
}

These cases should unconditionally return true, instead of returning .is_ok(), and log the error.

Alternatively, it could bubble the error back up the original caller, but that might add significant complexity.

@GnomedDev GnomedDev added bug Something misbehaves or is not working. gateway Related to the `gateway` module. labels Apr 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something misbehaves or is not working. gateway Related to the `gateway` module.
Projects
None yet
Development

No branches or pull requests

2 participants