Claude Code. Any Model. The most powerful AI coding agent now speaks every language.
feat(adapters): stop an aborted internal call's fetch, queue and retries
Jack Rudenko0022af8451e6
diff --git a/packages/cli/src/handlers/composed-handler.ts b/packages/cli/src/handlers/composed-handler.tsindex 35365103..733aa822 100644--- a/packages/cli/src/handlers/composed-handler.ts+++ b/packages/cli/src/handlers/composed-handler.ts@@ -109,7 +109,17 @@ import {isCredentialRejection,respondAuthFailure,} from "./shared/auth-failure.js";-import { addSigningSecrets, credentialValuesFromRequest } from "./shared/call-context.js";+import {+ abortedResponse,+ addSigningSecrets,+ callAbortError,+ callAbortSignal,+ callAborted,+ credentialValuesFromRequest,+ raceCallAbort,+ sleepUnlessAborted,+ withCallSignal,+} from "./shared/call-context.js";import { sseResponseToJson } from "./shared/collect-sse-message.js";import type { ConnectionErrorKind } from "./shared/connection-error.js";import {@@ -180,26 +190,6 @@ interface ResponsesTurnWiring {codeMode?: CodeModeTurnHooks;}-/**- * Wait `ms`, or less if `signal` aborts first. Resolves `true` when it was- * aborted. A retry leg passes its turn signal so a client that disconnects- * during a 7b backoff does not hold the leg open for up to 30 s.- */-function sleepUnlessAborted(ms: number, signal?: AbortSignal): Promise<boolean> {- if (signal?.aborted) return Promise.resolve(true);- return new Promise<boolean>((resolve) => {- const onAbort = () => {- clearTimeout(timer);- resolve(true);- };- const timer = setTimeout(() => {- signal?.removeEventListener("abort", onAbort);- resolve(false);- }, ms);- signal?.addEventListener("abort", onAbort, { once: true });- });-}-/*** One request's running account of what network recovery cost it. Mutable, and* mutated only by `recoverConnection`.@@ -602,6 +592,42 @@ export class ComposedHandler implements ModelHandler {);}+ /**+ * The answer when an internal call's deadline passed (`call-context.ts`).+ * No classification, no recovery, nothing on stderr: the caller has already+ * stopped waiting and reports the timeout itself. One failure stats event,+ * so the attempt is still counted. Unreachable on a main request, which+ * never carries a call signal.+ */+ private respondCallAborted(+ startTime: number,+ fallbackMeta?: { chain: string[]; attempts: number }+ ): Response {+ log(`[${this.provider.displayName}] call stopped: its deadline passed`);+ try {+ this.emitStats({+ model_id: this.targetModel,+ provider_name: this.provider.name,+ stream_format: this.provider.streamFormat,+ latency_ms: Math.round(performance.now() - startTime),+ success: false,+ http_status: 408,+ error_class: "timeout",+ error_code: "call_aborted",+ token_strategy: this.options.tokenStrategy ?? "standard",+ adapter_name: this.getActiveAdapterName(),+ middleware_names: this.middlewareManager.getActiveNames(this.bareModelName),+ fallback_used: fallbackMeta !== undefined,+ fallback_chain: fallbackMeta?.chain,+ fallback_attempts: fallbackMeta?.attempts,+ invocation_mode: this.options.invocationMode ?? "auto-route",+ });+ } catch {+ // Stats must never crash claudish+ }+ return abortedResponse();+ }+/*** The ONE response shape for "claudish could not reach the host".*@@ -1146,6 +1172,11 @@ export class ComposedHandler implements ModelHandler {// several at once. It stays all-zero and contributes NOTHING to any stats// record unless a classified connection failure actually occurs.const recoveryTally = ComposedHandler.newRecoveryTally();+ // An internal call's deadline (the advisor panel gateway installs it).+ // Undefined on every request from Claude Code, and then every use below+ // collapses to the expression that ran before it existed.+ const callSignal = callAbortSignal(c);+ if (callSignal?.aborted) return this.respondCallAborted(startTime, fallbackMeta);// 1. Transform incoming Claude-format requestconst { claudeRequest, droppedParams } = transformOpenAIToClaude(payload);@@ -1454,7 +1485,10 @@ export class ComposedHandler implements ModelHandler {let binding: AuthBinding | undefined;if (this.provider.refreshAuth) {try {- binding = (await this.provider.refreshAuth()) || undefined;+ // Raced, not cancelled: a refresh is single-flight and shared with+ // other requests, so an aborted call stops WAITING for it and nothing+ // more.+ binding = (await raceCallAbort(this.provider.refreshAuth(), callSignal)) || undefined;// Quota is DELIBERATELY not fetched here.//// This used to await getQuotaRemaining with a 2s cap on every single@@ -1476,6 +1510,8 @@ export class ComposedHandler implements ModelHandler {// user across every provider in the chain — off a subscription onto// metered billing — for an outage on their own machine.//+ // A stopped call is not a failure to classify: no verdict, no stderr.+ if (callAborted(c)) return this.respondCallAborted(startTime, fallbackMeta);const conn = classifyConnectionError(err);if (conn) {// The refresh path's deadline is DELIBERATELY earlier than the fetch@@ -1698,8 +1734,9 @@ export class ComposedHandler implements ModelHandler {};let headers: Record<string, string>;try {- headers = await fetchHeaders(binding);+ headers = await raceCallAbort(fetchHeaders(binding), callSignal);} catch (err: any) {+ if (callAborted(c)) return this.respondCallAborted(startTime, fallbackMeta);const conn = classifyConnectionError(err);if (!conn) {// A credential failure this site can place is answered here — terminal@@ -1762,8 +1799,14 @@ export class ComposedHandler implements ModelHandler {// from turning a slow answer into a re-issued one.const deadlineAt = tier1DeadlineAt(c);const clamp = deadlineClamp(deadlineAt);- const doFetch = () =>- fetch(+ //+ // An internal call's deadline reaches this closure twice: a pre-start+ // check, so a queue that admits it late (or a transport retry that calls it+ // again) never starts a fetch, and the signal on the fetch, which also+ // governs the body read after `clamp.disarm()`.+ const doFetch = () => {+ if (callSignal?.aborted) return Promise.reject(callAbortError());+ return fetch(endpoint,mergeSignalIntoInit({@@ -1772,22 +1815,30 @@ export class ComposedHandler implements ModelHandler {body: serialized?.body ?? JSON.stringify(requestPayload),...requestInit,},- clamp.signal+ withCallSignal(clamp.signal, callSignal)));+ };+ // Every queue admission of this request: with the call's signal when one+ // is installed, so a queue that honours it drops the call while it waits;+ // called exactly as before otherwise.+ const enqueue = (fn: () => Promise<Response>): Promise<Response> =>+ callSignal+ ? this.provider.enqueueRequest!(fn, { signal: callSignal })+ : this.provider.enqueueRequest!(fn);let response: Response;try {try {- response = this.provider.enqueueRequest- ? await this.provider.enqueueRequest(doFetch)- : await doFetch();+ response = this.provider.enqueueRequest ? await enqueue(doFetch) : await doFetch();} finally {// Before a byte of the body is read, so the ceiling can only ever bound// connect-and-headers — never cut a response already arriving.clamp.disarm();}} catch (error: any) {+ // A stopped call first: no classification, no stderr, no recovery.+ if (callAborted(c)) return this.respondCallAborted(startTime, fallbackMeta);// A failure to even REACH the provider (DNS can't resolve, connection// refused, host unreachable) is a LOCAL network problem, not an upstream// server error. Surface it as a connection_error with an honest,@@ -2008,7 +2059,8 @@ export class ComposedHandler implements ModelHandler {// UNCLASSIFIED throw is rethrown unchanged, so the existing 500 route// out of here is untouched.const doParamRetry = async (sig?: AbortSignal): Promise<Response> => {- const retryHeaders = await fetchHeaders(binding);+ if (callSignal?.aborted) throw callAbortError();+ const retryHeaders = await raceCallAbort(fetchHeaders(binding), callSignal);retryHeaders["Content-Type"] = retrySerialized?.contentType ?? "application/json";return fetch(endpoint,@@ -2019,7 +2071,7 @@ export class ComposedHandler implements ModelHandler {body: retrySerialized?.body ?? JSON.stringify(requestPayload),...(this.provider.getRequestInit?.() || {}),},- sig+ withCallSignal(sig, callSignal)));};@@ -2027,6 +2079,7 @@ export class ComposedHandler implements ModelHandler {try {retryResp = await doParamRetry();} catch (err: any) {+ if (callAborted(c)) return this.respondCallAborted(startTime, fallbackMeta);const conn = classifyConnectionError(err);if (!conn) {// The re-fetch re-reads the headers, so a credential failure can@@ -2108,7 +2161,11 @@ export class ComposedHandler implements ModelHandler {// retry leg after it, sign with the artifact just minted. The headers// of the request the upstream rejected go with it, so a transport can// tell a stale failure from one naming the credential it holds now.- const refreshed = await this.provider.forceRefreshAuth!({ rejectedHeaders: headers });+ if (callSignal?.aborted) throw callAbortError();+ const refreshed = await raceCallAbort(+ this.provider.forceRefreshAuth!({ rejectedHeaders: headers }),+ callSignal+ );if (refreshed) {// The body was built for THIS binding's account (code mode renders// its encrypted reasoning and keys its records by it): a refresh@@ -2133,7 +2190,7 @@ export class ComposedHandler implements ModelHandler {binding = refreshed;endpoint = this.provider.getEndpoint(this.targetModel, binding);}- const retryHeaders = await fetchHeaders(binding);+ const retryHeaders = await raceCallAbort(fetchHeaders(binding), callSignal);// Same serialization as the primary request — this is a separate call// site and the easy one to forget, which is why both are pinned by// the same assertion.@@ -2148,7 +2205,7 @@ export class ComposedHandler implements ModelHandler {body: serialized?.body ?? JSON.stringify(requestPayload),...retryInit,},- sig+ withCallSignal(sig, callSignal)));};@@ -2271,6 +2328,7 @@ export class ComposedHandler implements ModelHandler {const answered = await settleAuthRetry(await doAuthRetry());if (answered) return answered;} catch (err: any) {+ if (callAborted(c)) return this.respondCallAborted(startTime, fallbackMeta);// CLASSIFY FIRST, exactly as in the refreshAuth catch above, and for a// sharper reason: this path covers BOTH `forceRefreshAuth()` AND the// raw retry `fetch` that follows it, so "the network dropped while we@@ -2545,13 +2603,20 @@ export class ComposedHandler implements ModelHandler {// against the guard rather than adding to it.let responseHeadersAt = Date.now();if (this.resolveStreamFormat() === "openai-responses-sse") {- const settled = await this.settleResponsesStreamHead(response, async () => {- const next = await (this.provider.enqueueRequest- ? this.provider.enqueueRequest(doFetch)- : doFetch());- responseHeadersAt = Date.now();- return next;- });+ const settled = await this.settleResponsesStreamHead(+ response,+ async () => {+ const next = await (this.provider.enqueueRequest ? enqueue(doFetch) : doFetch());+ responseHeadersAt = Date.now();+ return next;+ },+ // Ends the backoff wait when an internal call's deadline passes.+ callSignal+ );+ if (callAborted(c)) {+ if (settled.kind === "ok") await settled.response.body?.cancel().catch(() => {});+ return this.respondCallAborted(startTime, fallbackMeta);+ }if (settled.kind === "exhausted") {const waited = STREAM_RETRY_DELAYS_MS.slice(0, settled.attempts).reduce((sum, ms) => sum + ms,@@ -2601,8 +2666,12 @@ export class ComposedHandler implements ModelHandler {// as a 400 rendered inline rather than a status Claude Code silently retries.if (this.resolveStreamFormat() === "connect-proto") {const settled = await this.settleDevinStreamHead(response, () =>- this.provider.enqueueRequest ? this.provider.enqueueRequest(doFetch) : doFetch()+ this.provider.enqueueRequest ? enqueue(doFetch) : doFetch());+ if (callAborted(c)) {+ if (settled.kind === "ok") await settled.response.body?.cancel().catch(() => {});+ return this.respondCallAborted(startTime, fallbackMeta);+ }if (settled.kind !== "ok") {const isTerminal = settled.kind === "terminal";const httpStatus = isTerminal ? 400 : 503;@@ -2750,7 +2819,11 @@ export class ComposedHandler implements ModelHandler {});responsesTurn = {retry: {- issueLeg,+ // A leg composes its turn signal with an internal call's deadline,+ // and the issuer returns `aborted` before it starts once either fired.+ issueLeg: callSignal+ ? (body, turnSignal) => issueLeg(body, AbortSignal.any([turnSignal, callSignal]))+ : issueLeg,// Default scope: `openai-codex` on the subscription arm, the only// backend the stall data comes from; CLAUDISH_RESPONSES_STALL_MS// overrides it everywhere.diff --git a/packages/cli/src/handlers/shared/call-context.ts b/packages/cli/src/handlers/shared/call-context.tsindex c0e87d2a..143a0f0f 100644--- a/packages/cli/src/handlers/shared/call-context.ts+++ b/packages/cli/src/handlers/shared/call-context.ts@@ -223,3 +223,123 @@ export function releaseWhenBodyEnds(response: Response, release: () => void): Reheaders: response.headers,});}++// ─── Call abort ──────────────────────────────────────────────────────────────++/**+ * The Context key of an internal call's abort signal. Installed ONLY by a+ * caller that issues requests of its own with a deadline (the advisor panel+ * gateway); never on a request from Claude Code. Every reach point reads it+ * through `callAbortSignal`, which returns `undefined` for a main request, so+ * each composition below collapses to the code that ran before it existed.+ *+ * A Context variable, not `c.req.raw.signal`: the inbound request's signal is+ * the CLIENT going away, which the recovery ladder already reads with its own+ * meaning, and a main request must not acquire a second one.+ */+export const CALL_ABORT_SIGNAL_KEY = "claudishCallAbortSignal" as const;++/** Header on the answer to an aborted call. Produced, never compared by status. */+export const CALL_ABORTED_HEADER = "x-claudish-call-aborted";++declare module "hono" {+ interface ContextVariableMap {+ /** An internal call's deadline; see `CALL_ABORT_SIGNAL_KEY`. */+ claudishCallAbortSignal: AbortSignal;+ }+}++/** The call's abort signal, or `undefined` (every main request). */+export function callAbortSignal(c: Context | undefined): AbortSignal | undefined {+ return readCallVar<AbortSignal>(c, CALL_ABORT_SIGNAL_KEY);+}++/** True once the call's deadline has passed. Always false on a main request. */+export function callAborted(c: Context | undefined): boolean {+ return callAbortSignal(c)?.aborted === true;+}++/** The error a stopped reach point rejects with: a DOM `AbortError`. */+export function callAbortError(): Error {+ return new DOMException("the call's deadline passed; claudish stopped its work", "AbortError");+}++/**+ * Stop WAITING for `p` once `signal` aborts; `p` itself is not cancelled. For+ * work that is shared or unbilled (a single-flight token refresh, a quota+ * read), where cancelling would hurt other requests and waiting would hold+ * this one past its deadline. Without a signal, `p` is returned unchanged.+ *+ * The losing promise's rejection is owned here (a no-op `catch`), so a refresh+ * that fails after the abort won never surfaces as an unhandled rejection.+ */+export function raceCallAbort<T>(p: Promise<T>, signal?: AbortSignal): Promise<T> {+ if (!signal) return p;+ p.catch(() => {});+ if (signal.aborted) return Promise.reject(callAbortError());+ return new Promise<T>((resolve, reject) => {+ const onAbort = () => reject(callAbortError());+ signal.addEventListener("abort", onAbort, { once: true });+ p.then(+ (value) => {+ signal.removeEventListener("abort", onAbort);+ resolve(value);+ },+ (err) => {+ signal.removeEventListener("abort", onAbort);+ reject(err);+ }+ );+ });+}++/**+ * Wait `ms`, or less if `signal` aborts first. Resolves `true` when it was+ * aborted. The timer is cleared on abort and the listener removed on expiry,+ * so neither outlives the wait.+ */+export function sleepUnlessAborted(ms: number, signal?: AbortSignal): Promise<boolean> {+ if (signal?.aborted) return Promise.resolve(true);+ return new Promise<boolean>((resolve) => {+ const onAbort = () => {+ clearTimeout(timer);+ resolve(true);+ };+ const timer = setTimeout(() => {+ signal?.removeEventListener("abort", onAbort);+ resolve(false);+ }, ms);+ signal?.addEventListener("abort", onAbort, { once: true });+ });+}++/** `sig` composed with the call's signal; either alone when the other is absent. */+export function withCallSignal(+ sig: AbortSignal | undefined,+ callSignal: AbortSignal | undefined+): AbortSignal | undefined {+ if (!callSignal) return sig;+ if (!sig) return callSignal;+ return AbortSignal.any([sig, callSignal]);+}++/**+ * The answer to a call whose deadline passed: 408 with `CALL_ABORTED_HEADER`.+ * Its caller has already stopped waiting; this exists so every path returns a+ * Response instead of throwing, and so nothing downstream classifies it.+ */+export function abortedResponse(): Response {+ return new Response(+ JSON.stringify({+ type: "error",+ error: {+ type: "timeout_error",+ message: "claudish stopped this call: its deadline passed",+ },+ }),+ {+ status: 408,+ headers: { "content-type": "application/json", [CALL_ABORTED_HEADER]: "1" },+ }+ );+}diff --git a/packages/cli/src/handlers/shared/gemini-queue.ts b/packages/cli/src/handlers/shared/gemini-queue.tsindex 758fe6b2..3fb7e554 100644--- a/packages/cli/src/handlers/shared/gemini-queue.ts+++ b/packages/cli/src/handlers/shared/gemini-queue.ts@@ -12,6 +12,7 @@*/import { log } from "../../logger.js";+import { callAbortError } from "./call-context.js";/*** Queued request with Promise callbacks@@ -20,6 +21,22 @@ interface QueuedRequest {fetchFn: () => Promise<Response>;resolve: (response: Response) => void;reject: (error: Error) => void;+ /** The caller's abort signal, when it passed one. */+ signal?: AbortSignal;+ /** Removes this entry from the queue on abort, while it is still waiting. */+ onAbort?: () => void;+}++/**+ * Called by the worker once it has taken an entry: the entry no longer waits in+ * the queue, so its abort listener goes, and an entry whose caller already+ * aborted is rejected instead of started. True when it was rejected.+ */+function rejectIfAborted(request: QueuedRequest): boolean {+ if (request.onAbort) request.signal?.removeEventListener("abort", request.onAbort);+ if (!request.signal?.aborted) return false;+ request.reject(callAbortError());+ return true;}/**@@ -82,7 +99,12 @@ export class GeminiRequestQueue {* @returns Promise that resolves with the response* @throws Error if queue is full*/- async enqueue(fetchFn: () => Promise<Response>): Promise<Response> {+ async enqueue(+ fetchFn: () => Promise<Response>,+ opts?: { signal?: AbortSignal }+ ): Promise<Response> {+ const signal = opts?.signal;+ if (signal?.aborted) throw callAbortError();// Check queue size limitif (this.queue.length >= this.maxQueueSize) {log(@@ -97,7 +119,20 @@ export class GeminiRequestQueue {fetchFn,resolve,reject,+ signal,};+ // An abort while the entry still WAITS removes it and rejects at once:+ // nothing of the call starts after its deadline, and it stops holding a+ // place in line. Once the worker has taken it, the worker checks again.+ if (signal) {+ queuedRequest.onAbort = () => {+ const index = this.queue.indexOf(queuedRequest);+ if (index === -1) return;+ this.queue.splice(index, 1);+ reject(callAbortError());+ };+ signal.addEventListener("abort", queuedRequest.onAbort, { once: true });+ }this.queue.push(queuedRequest);log(`[GeminiQueue] Request enqueued (queue length: ${this.queue.length})`);@@ -123,12 +158,15 @@ export class GeminiRequestQueue {while (this.queue.length > 0) {const request = this.queue.shift();if (!request) break;+ if (rejectIfAborted(request)) continue;log(`[GeminiQueue] Processing request (${this.queue.length} remaining in queue)`);try {// Wait for next available slotawait this.waitForNextSlot();+ // Aborted during the rate-limit wait: never start it.+ if (rejectIfAborted(request)) continue;// Execute the requestconst response = await request.fetchFn();diff --git a/packages/cli/src/handlers/shared/openrouter-queue.ts b/packages/cli/src/handlers/shared/openrouter-queue.tsindex 17af99c5..1bd27d12 100644--- a/packages/cli/src/handlers/shared/openrouter-queue.ts+++ b/packages/cli/src/handlers/shared/openrouter-queue.ts@@ -20,6 +20,7 @@*/import { getLogLevel, log } from "../../logger.js";+import { callAbortError } from "./call-context.js";/*** Queued request with Promise callbacks@@ -28,6 +29,10 @@ interface QueuedRequest {fetchFn: () => Promise<Response>;resolve: (response: Response) => void;reject: (error: Error) => void;+ /** The caller's abort signal, when it passed one. */+ signal?: AbortSignal;+ /** Removes this entry from the queue on abort, while it is still waiting. */+ onAbort?: () => void;}/**@@ -52,6 +57,18 @@ interface RateLimitState {total429Errors: number;}+/**+ * Called by the worker once it has taken an entry: the entry no longer waits in+ * the queue, so its abort listener goes, and an entry whose caller already+ * aborted is rejected instead of started. True when it was rejected.+ */+function rejectIfAborted(request: QueuedRequest): boolean {+ if (request.onAbort) request.signal?.removeEventListener("abort", request.onAbort);+ if (!request.signal?.aborted) return false;+ request.reject(callAbortError());+ return true;+}+/*** Queue statistics for monitoring*/@@ -128,7 +145,12 @@ export class OpenRouterRequestQueue {* @returns Promise that resolves with the response* @throws Error if queue is full*/- async enqueue(fetchFn: () => Promise<Response>): Promise<Response> {+ async enqueue(+ fetchFn: () => Promise<Response>,+ opts?: { signal?: AbortSignal }+ ): Promise<Response> {+ const signal = opts?.signal;+ if (signal?.aborted) throw callAbortError();// Check queue size limitif (this.queue.length >= this.maxQueueSize) {if (getLogLevel() === "debug") {@@ -147,7 +169,20 @@ export class OpenRouterRequestQueue {fetchFn,resolve,reject,+ signal,};+ // An abort while the entry still WAITS removes it and rejects at once:+ // nothing of the call starts after its deadline, and it stops holding a+ // place in line. Once the worker has taken it, the worker checks again.+ if (signal) {+ queuedRequest.onAbort = () => {+ const index = this.queue.indexOf(queuedRequest);+ if (index === -1) return;+ this.queue.splice(index, 1);+ reject(callAbortError());+ };+ signal.addEventListener("abort", queuedRequest.onAbort, { once: true });+ }this.queue.push(queuedRequest);if (getLogLevel() === "debug") {@@ -177,6 +212,7 @@ export class OpenRouterRequestQueue {while (this.queue.length > 0) {const request = this.queue.shift();if (!request) break;+ if (rejectIfAborted(request)) continue;if (getLogLevel() === "debug") {log(`[OpenRouterQueue] Processing request (${this.queue.length} remaining in queue)`);@@ -185,6 +221,8 @@ export class OpenRouterRequestQueue {try {// Wait for next available slotawait this.waitForNextSlot();+ // Aborted during the rate-limit wait: never start it.+ if (rejectIfAborted(request)) continue;// Execute the requestconst response = await request.fetchFn();diff --git a/packages/cli/src/providers/transport/gemini-apikey.ts b/packages/cli/src/providers/transport/gemini-apikey.tsindex 981834d3..40ef49a6 100644--- a/packages/cli/src/providers/transport/gemini-apikey.ts+++ b/packages/cli/src/providers/transport/gemini-apikey.ts@@ -42,9 +42,12 @@ export class GeminiProviderTransport implements ProviderTransport {* Rate-limited request via GeminiRequestQueue singleton.* Serializes all Gemini requests to prevent quota exhaustion.*/- async enqueueRequest(fetchFn: () => Promise<Response>): Promise<Response> {+ async enqueueRequest(+ fetchFn: () => Promise<Response>,+ opts?: { signal?: AbortSignal }+ ): Promise<Response> {const queue = GeminiRequestQueue.getInstance();- return queue.enqueue(fetchFn);+ return queue.enqueue(fetchFn, opts);}}diff --git a/packages/cli/src/providers/transport/openrouter.ts b/packages/cli/src/providers/transport/openrouter.tsindex daf0474e..d7ce9e26 100644--- a/packages/cli/src/providers/transport/openrouter.ts+++ b/packages/cli/src/providers/transport/openrouter.ts@@ -58,8 +58,11 @@ export class OpenRouterProviderTransport implements ProviderTransport {};}- async enqueueRequest(fetchFn: () => Promise<Response>): Promise<Response> {- return this.queue.enqueue(fetchFn);+ async enqueueRequest(+ fetchFn: () => Promise<Response>,+ opts?: { signal?: AbortSignal }+ ): Promise<Response> {+ return this.queue.enqueue(fetchFn, opts);}/**