Skip to content

fix(api): Poe ignores caller cancellation and the configured request timeout #2508

Open

Description

@easonLiangWorldedtech

Symptom

Poe does not honour the caller's metadata.abortSignal and the configured request timeout the way the merged providers do. Cancelling a request mid-flight does not stop the model fetch, the SDK call, or the stream, and a completion that lands after the cancel is still delivered to the caller.

Evidence on main

  • The provider does not race its SDK promise through rejectOnAbort (src/api/providers/utils/abort-signal.ts:226), so a cancellation during SDK retry backoff or a request that never settles waits for the transport.
  • The caller signal is handed to the SDK instead of a per-request bridge. The pinned openai SDK does signal.addEventListener('abort', () => controller.abort()) in client.mjs and never removes the listener, so a long-lived caller signal accumulates one listener and one request controller per request.
  • Nothing re-checks the signal after the stream ends, so an iterator that closes without throwing - which the SDK does when it converts an aborted read into a normal end - reports success.
  • src/api/providers/poe.ts has no rejectOnAbort, no isRequestAborted and no resolveModelWithAbort call, and the pre-abort guard for completePrompt sits inside the try, so this.poe(id) and the model fetch still run after a cancel.

Expected

The provider follows the shared contract exactly as requesty.ts (#1537) and zoo-gateway.ts (#2430) do: bridge the caller signal and dispose it on every exit path, race the SDK promise and the model lookup through rejectOnAbort / resolveModelWithAbort, guard the emit loop and the post-loop end, and normalise an SDK-side abort with isRequestAborted so a cancellation surfaces as AbortError with the message The <provider> request was aborted.

Scope

Provider file plus its spec. No change to utils/abort-signal.ts or utils/request-timeout.ts; the timeout-versus-body-consumption question is tracked separately in #2486.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions