Repository navigation
fix(media): bill a completed fal generation even when a Stop ends its download - #9106
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
1 issue found across 8 files
Confidence score: 4/5
- In
falai-video.ts, a completed Fal request can incur a charge without recording it if the output URL is missing or unrecognized. Record the cost immediately afterrunFalQueue, before validating the URL.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/sim/lib/media/falai-video.ts">
<violation number="1" location="apps/sim/lib/media/falai-video.ts:185">
P2: A completed request with a missing or unrecognized output URL throws before `recordFalCost` runs, leaving Fal’s charge unrecorded. Record the cost immediately after `runFalQueue`, before validating the media URL.</violation>
</file>
[Critical impact] The PR appears safe to merge; no new actionable issues were found. SummaryThe PR records completed fal audio and video costs before reading or downloading media. Cost lookups have their own 10-second limit and return a fallback charge when that limit expires.
|
|
@greptileai review |
|
@cubic-dev-ai review |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 8 files
Reply with feedback, questions, or to request a fix.
Turn on auto-fix | Re-trigger cubic
|
@greptileai review |
|
@cubic-dev-ai review |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
recordServiceCostran, so a generation fal charged for was never billed. The cost lookup and the download both took the caller's abort signal, and the cost was recorded only after both.generateFalAudio/generateFalVideonow take anonCostrecorder and bill through it once fal has returned the result, before the download that a Stop can still end. The mothership audio/video tools wireonCosttorecordServiceCostinside the meter scope and no longer record afterwards, so each generation is billed exactly once.getFalAICostMetadatanow has its own 10s bound (via the existingwithinDeadline), and past it the fallback floor is billed instead of nothing. A Stop during the lookup waits at most that bound, then the generation fails without downloading.Type of Change
Testing
lib/media/falai.test.tsruns the real queue, pricing and download path with stubbed fal HTTP. It covers a Stop during the download after completion (audio and video, billed once), a Stop during the cost lookup (lookup finishes, billed once, no download), a lookup that hangs (floor billed once at the bound), the success path (billed exactly once), and a Stop before completion (cancelled, nothing billed). The first four fail on staging.model-boundaries.test.ts: the tools bill once throughonCosteven when the generation then fails.Checklist