refactor(api): move hand-written abort bridges to the shared helper

Offen
#2,486 9 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 3 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
42/100
Issue-Typ
Refactoring
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
eslint, typescript

Rechercherichtung

Start with src/api/providers/utils/abort-signal.ts and its callers, then review the listed provider locations and tests. The work covers seven providers, timeout helper consolidation, and two lint selectors, so map each special callback and controller use before changing the shared helper. Done means the providers’ tests pass and both selectors have zero violations, while the two fetchers/modelCache.ts listeners remain untouched.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Seven providers on main bridge the caller's abortSignal with their own AbortController and abort listener. bridgeExternalAbortSignal in src/api/providers/utils/abort-signal.ts does the same work. anthropic.ts, anthropic-vertex.ts, minimax.ts and xai.ts already use it. Each hand-written copy adds one more place for a listener leak or a missed pre-aborted check.

Sites at origin/main 66b07e0e65:

  • bedrock.ts (~593): its 10-minute timer also aborts the request controller.
  • lm-studio.ts (~137) and qwen-code.ts (~293): both need a signal even with no caller signal, and abort the controller in finally.
  • openai-native.ts (~471, attachExternalAbort): the controller is exposed to the stop-button path.
  • openai-codex.ts (~524): both transports abort through the controller.
  • native-ollama.ts (~481 and ~736): the abort callback also calls client.abort().
  • vscode-lm.ts (~1198 and ~1684): the callback cancels a token source and records abortedByCaller.

fetchers/modelCache.ts has two abort listeners. They are not request bridges, so leave them as they are.

The helper returns only a signal, and returns undefined when there is no caller signal. Most sites above need a controller or an extra callback. Extend the helper first, for example with an optional controller and an onAbort hook. Then migrate each site and keep its provider tests green.

Also in scope:

  • main has two createTimeoutError helpers: one in utils/abort-signal.ts and one in utils/request-timeout.ts with a phase argument. Keep one. Move the callers.
  • After the migration, add a lint selector in packages/config-eslint/api-provider-hygiene.js that flags addEventListener("abort", …) outside the helper. Add one that flags a hand-built TimeoutError. Both need zero violations when they land.

Context: review of #1535 and the open abort PRs #1545 and #1311.

Vorherrschende Sprache
TypeScript
Sterne
2k
Forks
301
Ø Merge
3 T. 14 Std.
Gemergte PRs (30 T.)
103

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus Zoo-Code-Org/Zoo-Code

Alle Issues in Zoo-Code-Org/Zoo-Code

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.