Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,11 @@ class Replicate {
const shouldRetry = method === 'GET' ?
(response) => (response.status === 429 || response.status >= 500) :
(response) => (response.status === 429);
const response = await withAutomaticRetries(async () => this.fetch(url, init), { shouldRetry });

// Workaround to fix `TypeError: Illegal invocation` error in Cloudflare Workers
// https://github.com/replicate/replicate-javascript/issues/134
const _fetch = this.fetch; // eslint-disable-line no-underscore-dangle
const response = await withAutomaticRetries(async () => _fetch(url, init), { shouldRetry });

if (!response.ok) {
const request = new Request(url, init);
Expand Down