Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review pls |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback". |
ThomasK33
left a comment
There was a problem hiding this comment.
The implementation looks solid.
One open question about the effectiveness of this PR, along with some style-related changes.
Side note: your commit messages have typos (fix: gracefull conection has spelling errors "graceful", "connection"), please squash these into a single well-written commit describing the change, e.g.: fix: serialize notification processing to maintain message order
a6c4e71 to
042111e
Compare
|
@codex review |
|
To use Codex here, create a Codex account and connect to github. |
042111e to
afd0125
Compare
|
@ThomasK33 I’ve updated the PR and fixed the issues you raised. This one is quite important, so I’d appreciate another look when you have time, thank you! |
|
This one is quite important 👍 |
Serialize notification processing to preserve order while keeping request handling uncoupled for cancellation. Notifications use a longer-lived inbound context so already-received messages drain after peer disconnect. Based on coder#8.
|
Hi @ThomasK33 - hope you’re doing well. Quick ping to see if you could take another look at the updated PR when you have a chance. I’ve fixed the issues you mentioned. Thank you! |
ThomasK33
left a comment
There was a problem hiding this comment.
Thanks again for the update, and apologies for the delay on my side. I appreciate your patience.
The direction and tests look good overall. I’d like to request one more round of changes, focused on queue safety (details are in the review comments):
- Use a bounded notification queue instead of an unbounded one.
- On overflow, fail fast with explicit connection cancellation and cause (no fallback to concurrent handling).
- Ensure
notificationWgremains balanced if enqueue fails, and define the queue size via a named constant.
Once that’s addressed, I’m happy to re-review quickly.
fd4dc9b to
46d2f23
Compare
|
Implemented the queue-safety changes requested in review:
|
|
@ThomasK33 thanks for the re-review and the detailed queue-safety notes. I’ve implemented the bounded queue + fail-fast overflow behavior as requested (named capacity constant, explicit overflow error/cause, and ensured notificationWg stays balanced on enqueue failure). Ordering remains serialized via the single processing goroutine, and I added a deterministic overflow test to lock in the behavior. On the queue limit specifically: I’m happy to discuss what a sensible default should be for this SDK (and whether we should consider making it configurable in the future). My current thinking was to pick a conservative fixed bound to avoid unbounded memory growth while still tolerating short bursts, but I’m very open to adjusting based on expected notification rates / consumer behavior. If you have a preferred bound (or guidance on how you’d like to size it-e.g., based on typical streaming update bursts), I can update the constant accordingly. Thanks again - once you’re happy with the queue limit choice, I think we should be in good shape to merge. |
ThomasK33
left a comment
There was a problem hiding this comment.
Thanks for sticking with this. I re-checked the latest updates, and this looks good to me now.
I'll look into getting CI running in another branch/PR and will rebase this before merging.
Fix notification processing order
Notifications were being processed concurrently, causing them to be handled out of order. This fix serializes notification processing through a dedicated queue and processing goroutine, ensuring notifications are handled in the exact order they are received.
Problem
When multiple notifications arrived in quick succession (e.g., streaming session updates), each notification spawned its own goroutine for processing. Due to goroutine scheduling, notifications could complete in a different order than they were received, breaking applications that depend on ordered message processing.
Solution
notificationQueuechannel to serialize notification processingprocessNotifications()goroutine that processes notifications sequentiallyreceive()loop to queue notifications instead of processing them concurrentlyChanges
Connectionstruct: AddednotificationQueue chan *anyMessagefieldNewConnection(): StartsprocessNotifications()goroutinereceive(): Queues notifications instead of spawning goroutinesprocessNotifications(): New method that sequentially processes queued notificationsTesting
TestPromptCancellationSendsCancelAndAllowsNewSessionwhich has a pre-existing timing issue)Backward Compatibility
Fully backward compatible - public API unchanged, only internal processing order modified.