Skip to content

Commit 96b724c

Browse files
committed
fix(video): poll nested fal models through the app queue
1 parent 25e88b7 commit 96b724c

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎apps/sim/lib/internal/video/client.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,31 @@ describe('Video provider client', () => {
9898
).toHaveLength(1)
9999
})
100100

101+
it('retrieves a nested endpoint result when fal omits the queue URLs', async () => {
102+
const app = 'fal-ai/kandinsky5'
103+
const model = `${app}/text-to-video`
104+
const request = `/${app}/requests/fal-1`
105+
vi.stubGlobal('fetch', async (url: string | URL) => {
106+
switch (new URL(url).pathname) {
107+
case `/${model}`:
108+
return jsonResponse({ request_id: 'fal-1' })
109+
case `${request}/status`:
110+
return jsonResponse({ status: 'COMPLETED' })
111+
case request:
112+
return jsonResponse({ video: { url: 'data:video/mp4;base64,dmlkZW8=' } })
113+
default:
114+
return new Response(null, { status: 405 })
115+
}
116+
})
117+
const result = generateVideo(
118+
{ provider: 'falai', apiKey: 'key', model, prompt: 'A cinematic sunrise' },
119+
{ requestId: 'request-1' }
120+
)
121+
const completion = expect(result).resolves.toMatchObject({ buffer: Buffer.from('video') })
122+
await vi.advanceTimersByTimeAsync(5000)
123+
await completion
124+
})
125+
101126
it('keeps the fal API key off a foreign polling origin', async () => {
102127
const mockFetch = vi
103128
.fn()

‎apps/sim/lib/internal/video/client.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,7 +781,8 @@ async function generateWithFalAI(
781781
throw new Error('Fal.ai queue response missing request_id')
782782
}
783783

784-
const requestUrl = `https://queue.fal.run/${endpoint}/requests/${encodeURIComponent(requestIdFal)}`
784+
const app = endpoint.split('/', 2).join('/')
785+
const requestUrl = `https://queue.fal.run/${app}/requests/${encodeURIComponent(requestIdFal)}`
785786
const statusUrl = falQueueUrl(
786787
getStringProperty(createData, 'status_url') || `${requestUrl}/status`
787788
)

0 commit comments

Comments
 (0)