fix: guard against nil onAck in result-returning *Async methods#702
fix: guard against nil onAck in result-returning *Async methods#702lmars wants to merge 1 commit into
Conversation
Calling AppendMessageAsync (or the UpdateMessageAsync/DeleteMessageAsync siblings) with a nil onAck caused a segfault when the server ACK arrived, because performMessageOperationAsync invoked the callback unconditionally. PublishWithResultAsync and PublishMultipleWithResultAsync had the same latent bug. Normalize a nil onAck to a no-op at the top of each, mirroring the nil-safety msgAckCallback.call already provides at the lower layer. This makes fire-and-forget patterns like AppendMessageAsync(msg, nil) valid, as the docs and AI-streaming use case assume. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThis pull request adds nil ChangesNil acknowledgment callback handling
🎯 2 (Simple) | ⏱️ ~8 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
AppendMessageAsync(msg, nil)(and theUpdateMessageAsync/DeleteMessageAsyncsiblings) segfaulted when the server ACK arrived, becauseperformMessageOperationAsyncinvoked the callback unconditionally atrealtime_channel.go:908.PublishWithResultAsyncandPublishMultipleWithResultAsync.onAckto a no-op at the top of each — mirroring the nil-safety thatmsgAckCallback.callalready provides at the lower layer.Surfaced by ably/docs#3351, where a fire-and-forget append example using
AppendMessageAsync(msg, nil)crashed at runtime.Test plan
TestRealtimeChannel_MessageUpdates/AppendMessageAsync/nil_onAck_is_treated_as_fire-and-forget— callsAppendMessageAsync(msg, nil), then round-trips a follow-up syncAppendMessageso we know the ACK for the nil-callback append landed without panicking the connection's read loop. Passes againstnonprod:sandboxin ~0.6s.go vet ./ably/...cleango build ./...clean🤖 Generated with Claude Code
Summary by CodeRabbit