-
Notifications
You must be signed in to change notification settings - Fork 1
fix(NATSRS-008-3): CU-86akbhh82 2 review findings across 2 files #140
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -380,16 +380,24 @@ impl Service { | |
| loop { | ||
| tokio::select! { | ||
| Some(ping) = pings.next() => { | ||
| let Some(reply) = ping.reply else { | ||
| debug!("ignoring PING request without a reply subject"); | ||
| continue; | ||
| }; | ||
| let pong = serde_json::to_vec(&PingResponse{ | ||
| kind: "io.nats.micro.v1.ping_response".to_string(), | ||
| name: info.name.clone(), | ||
| id: info.id.clone(), | ||
| version: info.version.clone(), | ||
| metadata: info.metadata.clone(), | ||
| })?; | ||
| client.publish(ping.reply.unwrap(), pong.into()).await?; | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π unwrap() on reply subject in service verb dispatch loop can panic the whole service task In π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer |
||
| client.publish(reply, pong.into()).await?; | ||
| }, | ||
| Some(info_request) = infos.next() => { | ||
| let Some(reply) = info_request.reply else { | ||
| debug!("ignoring INFO request without a reply subject"); | ||
| continue; | ||
| }; | ||
| let info = info.clone(); | ||
|
|
||
| let endpoints: Vec<endpoint::Info> = { | ||
|
|
@@ -407,9 +415,13 @@ impl Service { | |
| ..info | ||
| }; | ||
| let info_json = serde_json::to_vec(&info).map(Bytes::from)?; | ||
| client.publish(info_request.reply.unwrap(), info_json.clone()).await?; | ||
| client.publish(reply, info_json.clone()).await?; | ||
| }, | ||
| Some(stats_request) = stats.next() => { | ||
| let Some(reply) = stats_request.reply else { | ||
| debug!("ignoring STATS request without a reply subject"); | ||
| continue; | ||
| }; | ||
| if let Some(stats_callback) = stats_callback.as_mut() { | ||
| let mut endpoint_stats_locked = endpoints_state.lock().unwrap(); | ||
| for (key, value) in &mut endpoint_stats_locked.endpoints { | ||
|
|
@@ -425,7 +437,7 @@ impl Service { | |
| started, | ||
| endpoints: endpoints_state.lock().unwrap().endpoints.values().cloned().map(Into::into).collect(), | ||
| })?; | ||
| client.publish(stats_request.reply.unwrap(), stats.into()).await?; | ||
| client.publish(reply, stats.into()).await?; | ||
| }, | ||
| else => break, | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π unwrap() on publish inside spawned heartbeat responder task can panic the task silently
In
Messages::poll_next(impl offutures_util::Stream for Messages), replaced the.publish(subject, Bytes::from_static(b"")).await.unwrap()call inside the spawned heartbeat-respondertokio::task::spawnwith anif let Err(err) = ... { error!(...) }pattern, matching the existing non-panicking style used for the analogous flow-control publish inOrdered::poll_next(which uses.ok()). This removes the panic-on-publish-failure path while still surfacing the failure via a log line instead of silently dropping it. Addederrorto thetracingimport list at the top of the file to support the new log call. No other behavior changed.π€ Prompt for AI agents
fix confidence: π‘ 85 medium β react π/π to teach the reviewer