jackwener/OpenCLI · error · TimeoutError

MiniMax music generation

Error message

MiniMax music generation

What it means

A TimeoutError thrown by generateMusic() when the AbortController fires because the POST to the MiniMax music_generation endpoint did not complete within timeoutSeconds. The fetch is aborted mid-flight, so the outcome is ambiguous: the request may have been accepted and billed even though no response arrived. The library surfaces the timeout with an explicit warning that there is no task id to resume from.

Source

Thrown at clis/minimax/utils.js:60

export async function generateMusic(region, apiKey, body, timeoutSeconds) {
    const controller = new AbortController();
    const timer = setTimeout(() => controller.abort(), timeoutSeconds * 1000);
    timer.unref?.();
    let response;
    try {
        response = await fetch(region.endpoint, {
            method: 'POST',
            headers: {
                authorization: `Bearer ${apiKey}`,
                'content-type': 'application/json',
                accept: 'application/json',
            },
            body: JSON.stringify(body),
            signal: controller.signal,
        });
    } catch (error) {
        if (controller.signal.aborted) {
            throw new TimeoutError('MiniMax music generation', timeoutSeconds, 'The request may have been accepted; result and billing state are unknown. The API exposes no task id to resume, so check account history before submitting again.');
        }
        throw new CommandExecutionError(
            `MiniMax music request failed: ${error?.message ?? error}`,
            `Check that ${region.host} is reachable. The request may have reached MiniMax; check account history before retrying.`,
        );
    } finally {
        clearTimeout(timer);
    }
    if (response.status === 401 || response.status === 403) {
        throw new AuthRequiredError(region.host, `MiniMax ${region.host} rejected ${MINIMAX_API_KEY_VAR} (HTTP ${response.status}).`);
    }
    if (!response.ok) {
        throw new CommandExecutionError(`MiniMax music returned HTTP ${response.status} from ${region.host}`);
    }
    try {
        return await response.json();
    } catch (error) {
        throw new CommandExecutionError(`MiniMax music returned malformed JSON: ${error?.message ?? error}`);

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run with a larger timeout (e.g. --timeout 120 or whatever flag maps to timeoutSeconds) before retrying.
  2. Check your MiniMax account history/billing before resubmitting — the request may have succeeded server-side despite the client timeout.
  3. Verify network reachability of the region host (curl -I https://api.minimax.io) and retry on a stable connection.
  4. If timeouts are persistent on one region, try the other MUSIC_REGIONS host (global vs cn).

Example fix

// before
generateMusic(region, apiKey, body, 10);

// after
generateMusic(region, apiKey, body, 120);
Defensive patterns

Strategy: retry

Try / catch

// catch TimeoutError and check account state before retrying
try {
  const res = await generateMusic(region, apiKey, body, 120);
} catch (e) {
  if (e instanceof TimeoutError) {
    console.warn('Check MiniMax account history before resubmitting — request may be billed.');
    // then retry once with a larger timeout
  } else throw e;
}

Prevention

When it happens

Trigger: fetch(region.endpoint, {signal: controller.signal}) rejects with an AbortError after setTimeout(() => controller.abort(), timeoutSeconds * 1000) fired — the MiniMax API took longer than the configured timeout to respond to the music generation POST.

Common situations: Very low custom --timeout values; slow or saturated networks; MiniMax region hosts (api.minimax.io / api.minimaxi.com) degraded or under heavy load; long/complex prompts where generation exceeds the client timeout while the server still completes and bills the job.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/a6ee21f6ba8d08cb. Report an issue: GitHub.