fix(liveWatcher): ensure idempotency on cancelRequest and detailed error reporting
This commit is contained in:
parent
f558ef4c88
commit
680c080c78
2 changed files with 6 additions and 3 deletions
|
|
@ -391,7 +391,7 @@ export class LiveWatcher {
|
|||
}): void {
|
||||
if (!this.isWatcherActive) return;
|
||||
const entry = this.buffer.find(e => e.id === params.requestId);
|
||||
if (!entry) return;
|
||||
if (!entry || (entry.endTime !== undefined && entry.status === 'completed')) return;
|
||||
|
||||
entry.endTime = Date.now();
|
||||
entry.durationMs = entry.endTime - entry.startTime;
|
||||
|
|
@ -426,7 +426,7 @@ export class LiveWatcher {
|
|||
public cancelRequest(requestId: string): void {
|
||||
if (!this.isWatcherActive) return;
|
||||
const entry = this.buffer.find(e => e.id === requestId);
|
||||
if (!entry) return;
|
||||
if (!entry || entry.endTime !== undefined) return;
|
||||
|
||||
entry.endTime = Date.now();
|
||||
entry.durationMs = entry.endTime - entry.startTime;
|
||||
|
|
|
|||
|
|
@ -627,7 +627,9 @@ export class RevolverEngine {
|
|||
// If we reached here, all tiers and all candidates failed
|
||||
cleanupTimers();
|
||||
if (onFailure) onFailure('all_tiers_exhausted');
|
||||
const finalErrorMessage = lastError ? lastError.message : 'All model tiers and provider keys are exhausted or rate-limited.';
|
||||
const finalErrorMessage = lastError?.cause?.message
|
||||
? `${lastError.message}: ${lastError.cause.message}`
|
||||
: (lastError ? lastError.message : 'All model tiers and provider keys are exhausted or rate-limited.');
|
||||
|
||||
const journey: RequestFallbackJourney = {
|
||||
requestId,
|
||||
|
|
@ -673,6 +675,7 @@ export class RevolverEngine {
|
|||
}));
|
||||
res.end();
|
||||
} else {
|
||||
res.setHeader('Cache-Control', 'no-cache, no-transform');
|
||||
res.status(503).json({
|
||||
error: {
|
||||
message: `[Revolver Fallback Error]: ${finalErrorMessage}`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue