-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request
Description
Description
The token_spend calculation is incorrect when multiple webhooks run concurrently using the same GitHub API token.
Root Cause
The CountingRequester wrapper is shared across webhook instances when they reuse the same GitHub API client:
# In GithubWebhook.__init__()
if isinstance(requester, CountingRequester):
# Reuse existing wrapper (SHARED across webhooks!)
self.requester_wrapper = requesterImpact
When 2+ webhooks run concurrently with the same token:
- Both record
initial_count = 100at start - Webhook A makes 5 calls, Webhook B makes 3 calls → shared counter = 108
- Both calculate
token_spend = 108 - 100 = 8(incorrect for both)
The initial_rate_limit and final_rate_limit fields are also affected.
Location
webhook_server/libs/github_api.py-GithubWebhook.__init__()and_update_context_metrics()
Possible Fixes
- Per-webhook tracking - Create a new CountingRequester per webhook instead of sharing
- Atomic snapshot - Track per-webhook deltas using context-based counters
- Rate limit delta - Use actual GitHub rate limit API at start/end (adds 2 API calls overhead)
Labels
- bug
- enhancement
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingenhancementNew feature or requestNew feature or request