Skip to content
Source
Sign inSign up
TanStack/schemas

Retry transient failures on each Replicate catalog page. (#662) #663

Mergedtombeckenhammerged 1 commit intomain fromrefs/pull/663/headmerged by tombeckenham View on GitHub

Showing 5 changed files with 79 additions and 7 deletions (loading 2).

x
0 of 5 viewed, 5 left
63 additions and 1 deletionsrc/server/providers/adapters/replicate.test.tsModified
View file
@@ -1,4 +1,4 @@
-import { describe, expect, it } from 'vitest'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
​
import { classifyAndBundle } from '#/server/ingest/sync.ts'
import listing from '../fixtures/replicate-models.json'
@@ -658,6 +658,68 @@
globalThis.fetch = original
+​
+ describe('a 502 on a later page', () => {
+ const PAGE_2 = 'https://api.replicate.com/v1/models?cursor=abc'
+​
+ beforeEach(() => {
+ vi.useFakeTimers()
+ })
+ afterEach(() => {
+ vi.unstubAllGlobals()
+ vi.useRealTimers()
+ })
+​
+ function stubCatalog(page2: () => Response): ReturnType<typeof vi.fn> {
+ const fetchMock = vi.fn((url: string) => {
+ const href = String(url)
+ if (href === PAGE_2) return Promise.resolve(page2())