Skip to content
Merged
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
9 changes: 8 additions & 1 deletion agent/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,14 @@ func newSession(ctx context.Context, agent *Agent, delay time.Duration, sessionI
)

if err != nil {
s.errs <- err
// since we are returning without launching the session goroutine, we
// need to provide the delay that is guaranteed by calling this
// function. We launch a goroutine so that we only delay the retry and
// avoid blocking the main loop.
go func() {
time.Sleep(delay)
s.errs <- err
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.

Just curious, what happens if the context gets done in the mean time ?

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.

Good point, I guess this wouldn't have a listener anymore. Wondering if we should call s.sendError(err) instead, which selects between writing the error and the session closed channel being closed?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Nothing: this is a buffered channel. If someone is listening, they pick it up. If no one is listening, it goes into the buffer immediately and the channel then gets garbage collected.

}()
return s
}

Expand Down