Skip to content
Open
Changes from 1 commit
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
10 changes: 4 additions & 6 deletions token.go
Original file line number Diff line number Diff line change
Expand Up @@ -1192,18 +1192,16 @@ func (t *tokenProcessor) iterateResponse() error {
func (t tokenProcessor) nextToken() (tokenStruct, error) {
// we do this separate non-blocking check on token channel to
// prioritize it over cancellation channel
select {
case tok, more := <-t.tokChan:
err, more := tok.(error)
if more {
if len(t.tokChan) > 0 {
tok := <-t.tokChan
err, ok := tok.(error)
if ok {
t.sess.LogF(t.ctx, msdsn.LogDebug, "nextToken returned an error:"+err.Error())
// this is an error and not a token
return nil, err
} else {
return tok, nil
}
default:
// there are no tokens on the channel, will need to wait
}
Comment on lines 1195 to 1210
Copy link

Copilot AI Feb 2, 2026

Choose a reason for hiding this comment

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

The PR description states that the code was changed to use len() to check the channel length before receiving, but the actual changes still use a select statement with a default case. The PR description does not match the implementation. The actual fix addresses the variable shadowing bug where 'more' was being overwritten by the type assertion result, but does not implement the len()-based approach described.

Copilot uses AI. Check for mistakes.

select {
Expand Down