{"record":{"id":"a6ee21f6ba8d08cb","repo":"jackwener/OpenCLI","slug":"minimax-music-generation","errorCode":null,"errorMessage":"MiniMax music generation","messagePattern":"MiniMax music generation","errorType":"exception","errorClass":"TimeoutError","httpStatus":null,"severity":"error","filePath":"clis/minimax/utils.js","lineNumber":60,"sourceCode":"export async function generateMusic(region, apiKey, body, timeoutSeconds) {\n    const controller = new AbortController();\n    const timer = setTimeout(() => controller.abort(), timeoutSeconds * 1000);\n    timer.unref?.();\n    let response;\n    try {\n        response = await fetch(region.endpoint, {\n            method: 'POST',\n            headers: {\n                authorization: `Bearer ${apiKey}`,\n                'content-type': 'application/json',\n                accept: 'application/json',\n            },\n            body: JSON.stringify(body),\n            signal: controller.signal,\n        });\n    } catch (error) {\n        if (controller.signal.aborted) {\n            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.');\n        }\n        throw new CommandExecutionError(\n            `MiniMax music request failed: ${error?.message ?? error}`,\n            `Check that ${region.host} is reachable. The request may have reached MiniMax; check account history before retrying.`,\n        );\n    } finally {\n        clearTimeout(timer);\n    }\n    if (response.status === 401 || response.status === 403) {\n        throw new AuthRequiredError(region.host, `MiniMax ${region.host} rejected ${MINIMAX_API_KEY_VAR} (HTTP ${response.status}).`);\n    }\n    if (!response.ok) {\n        throw new CommandExecutionError(`MiniMax music returned HTTP ${response.status} from ${region.host}`);\n    }\n    try {\n        return await response.json();\n    } catch (error) {\n        throw new CommandExecutionError(`MiniMax music returned malformed JSON: ${error?.message ?? error}`);","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/minimax/utils.js#L42-L78","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run with a larger timeout (e.g. --timeout 120 or whatever flag maps to timeoutSeconds) before retrying.","Check your MiniMax account history/billing before resubmitting — the request may have succeeded server-side despite the client timeout.","Verify network reachability of the region host (curl -I https://api.minimax.io) and retry on a stable connection.","If timeouts are persistent on one region, try the other MUSIC_REGIONS host (global vs cn)."],"exampleFix":"// before\ngenerateMusic(region, apiKey, body, 10);\n\n// after\ngenerateMusic(region, apiKey, body, 120);","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// catch TimeoutError and check account state before retrying\ntry {\n  const res = await generateMusic(region, apiKey, body, 120);\n} catch (e) {\n  if (e instanceof TimeoutError) {\n    console.warn('Check MiniMax account history before resubmitting — request may be billed.');\n    // then retry once with a larger timeout\n  } else throw e;\n}","preventionTips":["Set generous timeouts (music generation can exceed 30s).","Never blindly resubmit on timeout — verify billing/account history first.","Prefer wired/stable networks for long media-generation calls.","Monitor MiniMax status for region-specific latency incidents."],"tags":["timeout","network","billing-ambiguity"],"backgroundTag":"request-timeout","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}