mirror of
https://github.com/larsbaunwall/vscode-copilot-bridge.git
synced 2025-10-05 22:22:59 +00:00
Cleanup: ensure single throttle guard and request-start instrumentation
Co-Authored-By: Lars Baunwall <larslb@thinkability.dk>
This commit is contained in:
parent
89bb2c0659
commit
e0bca1d50c
1 changed files with 0 additions and 12 deletions
|
|
@ -64,18 +64,6 @@ async function startBridge() {
|
|||
if (token && req.headers.authorization !== `Bearer ${token}`) {
|
||||
writeJson(res, 401, { error: { message: 'unauthorized', type: 'invalid_request_error', code: 'unauthorized' } });
|
||||
return;
|
||||
if (req.method === 'POST' && req.url?.startsWith('/v1/chat/completions')) {
|
||||
if (activeRequests >= maxConc) {
|
||||
res.writeHead(429, { 'Content-Type': 'application/json', 'Retry-After': '1' });
|
||||
res.end(JSON.stringify({ error: { message: 'too many requests', type: 'rate_limit_error', code: 'rate_limit_exceeded' } }));
|
||||
if (verbose) output?.appendLine(`429 throttled (active=${activeRequests}, max=${maxConc})`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
activeRequests++;
|
||||
if (verbose) output?.appendLine(`Request started (active=${activeRequests})`);
|
||||
|
||||
}
|
||||
if (req.method === 'POST' && req.url?.startsWith('/v1/chat/completions')) {
|
||||
if (activeRequests >= maxConc) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue