SIGN IN SIGN UP

Add support for `AbortSignal` to all API methods (#339)

This PR adds support for passing `AbortSignal` to all API methods that
make HTTP requests, these are passed directly into the native `fetch()`
implementation, so it's up to the user to handle the `AbortError` raised,
if any.

```js
const controller = new AbortController();
try {
  const prediction = await replicate.predictions.create({
    version: 'xyz',
    ...,
    signal: controller.signal,
  });
} catch (err) {
  if (err instanceof DOMException && err.name === "AbortError") {
    ...
  }
}
```

The `paginate` function also checks to see whether the signal was
aborted before proceeding to the next iteration. If so it returns immediately
to avoid making a redundant fetch call.

This allows the client to take advantage of various frameworks that provide
an `AbortSignal` instance to tear down any in flight requests.
A
Aron Carroll committed
ac5caba3fd6c931803923689ae8fb01486b64646
Parent: 37aa363
Committed by GitHub <noreply@github.com> on 3/26/2025, 5:30:42 PM