Skip to content

fix(musicgen): poll slow tracks; re-sign when the poll refuses the POST payment - #195

Merged
VickyXAI merged 1 commit into
mainfrom
fix/musicgen-async-poll
Oct 3, 2026
Merged

VickyXAI merged 1 commit into
mainfrom
fix/musicgen-async-poll

Conversation

@VickyXAI

@VickyXAI VickyXAI commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Found while testing every Arc payment path live.

Bug 1, all chains: for a track that outruns the inline window, the gateway answers 202 + poll_url and charges nothing until a poll completes. MusicGen treated that 202 body as the final result and failed with No track URL returned from API. It now polls using the shared pollImageJob, the same way ImageGen does.

Bug 2, Arc: the first poll was refused with 402 invalid_payment_requirements. The music POST signs a requirement with maxTimeoutSeconds: 300, but the poll checks against 600, and Circle's facilitator rejects the mismatch. When a poll refuses the POST's authorization, MusicGen fetches the poll's own 402 challenge and signs that instead; the gateway documents that a fresh signature from the same wallet works. The job settles once, so this can't double-charge. The branch is gated on walletMayPay, like every other signer. The root fix belongs in the gateway (the music POST should use 600, as the image routes do); that's a separate PR.

Tests

  • local.mjs: a 202 job is polled through in_progress to completion and the track is saved. Without the fix, this fails with the same error as the live run.
  • arc.local.mjs: replays the live Arc sequence (POST paid at 300s, poll refuses it, poll's own challenge signed fresh with Arc's USDC domain, track saved).
  • npm test: 796 pass.

Live on Arc: a 79s, 256 kbps MP3 was generated. The balance fell by exactly $0.1585 (one charge); settlement tx 0x536b3fb9….

🤖 Generated with Claude Code

The gateway answers a track that outruns its inline window with 202 +
poll_url and settles on the first completed poll. MusicGen read the 202
body as the result and failed with "No track URL returned from API" on
every slow track, on every chain. It now polls with the shared
pollImageJob, like ImageGen.

On Arc the first poll was also refused: the music POST signs a 300s
requirement and the poll verifies against 600s, which Circle rejects as
invalid_payment_requirements. When a poll refuses the POST authorization,
MusicGen signs the poll's own 402 challenge (the gateway documents that a
fresh signature from the same wallet works). The job settles once, so this
cannot double-charge.

Verified live on Arc: a 79s track, charged $0.1585 once.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@VickyXAI
VickyXAI merged commit 160e929 into main Oct 3, 2026
6 checks passed
@VickyXAI
VickyXAI deleted the fix/musicgen-async-poll branch October 3, 2026 02:37
@VickyXAI VickyXAI mentioned this pull request Oct 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant