Skip to content

fix: update request handling to use currentQueueAuthIndex#195

Merged
bbbugg merged 1 commit into
mainfrom
fix/queue-index
Jun 1, 2026
Merged

fix: update request handling to use currentQueueAuthIndex#195
bbbugg merged 1 commit into
mainfrom
fix/queue-index

Conversation

@bbbugg
Copy link
Copy Markdown
Member

@bbbugg bbbugg commented Jun 1, 2026

This pull request updates the way authentication indices are handled when forwarding requests and recording usage statistics in the RequestHandler class. Instead of always using the current authentication index (currentAuthIndex), the code now consistently uses the specific authentication index associated with each request. This change ensures that requests are correctly attributed to the proper authentication context, improving accuracy in both request forwarding and usage tracking.

Key changes:

Authentication Index Handling:

  • All calls to _forwardRequest and recordAttempt now use the authentication index specific to the current request (e.g., currentQueueAuthIndex or messageQueueAuthIndex) instead of the global currentAuthIndex. This ensures requests are routed and tracked using the correct authentication context. [1] [2] [3] [4] [5] [6] [7]

Method Signature Update:

  • The _forwardRequest method now accepts an optional authIndex parameter (defaulting to currentAuthIndex) and uses it to select the appropriate connection for forwarding requests, rather than always using the global index.

Error Handling Improvement:

  • Error messages thrown when no connection is found now reference the specific authIndex used, making debugging easier and error reporting more accurate.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes request forwarding and usage-attempt tracking to use the auth index associated with the active message queue (rather than the global currentAuthIndex), improving correctness when retries/account switching occur mid-request.

Changes:

  • Forward requests and record usage attempts using currentQueueAuthIndex during streaming/retry loops.
  • Pass an explicit auth index into _forwardRequest(...) and update its implementation to look up the correct WebSocket connection.
  • For count-token style non-streaming requests, derive the auth index from ConnectionRegistry.getAuthIndexForRequest(requestId) and use it consistently for tracking + forwarding.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@bbbugg bbbugg merged commit 317db95 into main Jun 1, 2026
2 checks passed
@bbbugg bbbugg deleted the fix/queue-index branch June 1, 2026 10:06
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 4, 2026

🎉 此 PR 的修改已在版本 v1.3.1 中发布。
🎉 The changes in this PR have been released in version v1.3.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants