Skip to content
Open
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
5 changes: 5 additions & 0 deletions conn_process.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ func (c *connect) process(ctx context.Context, on *onProcess) error {
select {
case <-ctx.Done():
c.cancel()
// Wait for goroutine to finish before returning
select {
Copy link
Copy Markdown
Contributor

@kavirajk kavirajk Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bit of concern with this approach is, if you look at the background goroutine, it doesn't use/watch for passed in ctx for cancellation. It does give it to upstream handle method but we cannot gurantee that handle returns as soon as passed in ctx get cancelled.

the problem is, the whole point of canceling this method is to stop doing handle and return immediately.

With this change, we may indirectly may end-up waiting for handle to "finish".

I would handle the situation ideally like following.

  1. make the goroutine listen with two select case. a. handle to finish b. context to be done.
  2. Based on which ever comes first (a) or (b), we exit the go-routine.

Does it make sense?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case <-errCh:
case <-doneCh:
}
Comment on lines +119 to +123
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'untill' to 'until' in the PR title.

Copilot uses AI. Check for mistakes.
return ctx.Err()

case err := <-errCh:
Expand Down
Loading