jackwener/OpenCLI · error · CommandExecutionError
Midjourney cancel request failed: ${errorMessage(error)}
Error message
Midjourney cancel request failed: ${errorMessage(error)} What it means
cancelMidjourneyJob issues an in-page fetch to Midjourney's cancel endpoint with the job ID. If the browser-side fetch itself throws (network failure, page navigation, CSP block, JSON serialization error), the function wraps the underlying error message into CommandExecutionError. It covers request-level failures, not HTTP error statuses (those are handled after the fetch resolves).
Source
Thrown at clis/midjourney/utils.js:369
if (!job && !allowMissing) {
throw new EmptyResultError('midjourney status', `Job ${jobId} was not found in the current account.`);
}
return job;
}
export async function cancelMidjourneyJob(page, jobId) {
let result;
try {
result = unwrapEvaluateResult(await page.evaluate(async (id) => {
const response = await fetch('/api/job-cancel', {
method: 'POST',
headers: { 'Content-Type': 'application/json', 'X-CSRF-Protection': '1' },
body: JSON.stringify({ job_id: id }),
});
return { ok: response.ok, status: response.status, body: await response.text() };
}, jobId));
} catch (error) {
throw new CommandExecutionError(`Midjourney cancel request failed: ${errorMessage(error)}`);
}
if (!result?.ok) {
if ([401, 403].includes(Number(result?.status))) {
throw new AuthRequiredError(MIDJOURNEY_DOMAIN, 'Log into Midjourney in Chrome, then retry.');
}
throw new CommandExecutionError(
`Midjourney cancel request failed: HTTP ${result?.status ?? 0}${result?.body ? ` ${result.body}` : ''}`,
);
}
return result;
}
export async function getVisibleJobIds(page) {
const payload = unwrapEvaluateResult(await page.evaluate(() => {
const ids = new Set();
for (const link of document.querySelectorAll('a[href*="/jobs/"]')) {
const match = String(link.getAttribute('href') || '').match(/\/jobs\/([0-9a-f-]{36})/i);
if (match) ids.add(match[1].toLowerCase());View on GitHub (pinned to 49907e53dc)
Solutions
- Retry cancelMidjourneyJob in a fresh, loaded midjourney.com page/tab.
- Check network connectivity and any proxy/VPN interfering with the browser request.
- Confirm the cancel endpoint path/headers still match the current Midjourney site (inspect DevTools network tab for a manual cancel).
- Read the wrapped errorMessage in the thrown error for the root cause and address it specifically.
Example fix
// before
try {
await cancelMidjourneyJob(page, jobId);
} catch (e) { /* generic handling */ }
// after
try {
await cancelMidjourneyJob(page, jobId);
} catch (e) {
await page.reload({ waitUntil: 'networkidle' }); // refresh stale page context
await cancelMidjourneyJob(page, jobId); // retry once on transient request failure
} Defensive patterns
Strategy: try-catch
Validate before calling
// ensure page is on midjourney.com and still alive before cancelling
if (page.isClosed()) throw new Error('Browser page closed; reopen midjourney.com');
if (!page.url().includes('midjourney.com')) throw new Error('Navigate to midjourney.com before cancelling'); Try / catch
try {
await cancelMidjourneyJob(page, jobId);
} catch (e) {
if (String(e.message).includes('cancel request failed')) {
await page.reload({ waitUntil: 'networkidle' }); // recover stale page/network
await cancelMidjourneyJob(page, jobId);
} else throw e;
} Prevention
- Keep the driven tab open and on midjourney.com for the duration of operations
- Avoid cancelling during page navigation or while other in-page fetches run
- Check VPN/proxy stability for long-running sessions
- Read the wrapped root-cause message before retrying blindly
When it happens
Trigger: Calling cancelMidjourneyJob while the Chrome page is navigating/closed, network interruption mid-request, the cancel endpoint URL failing to resolve, or the injected fetch throwing (e.g. blocked by CSP or invalid CSRF headers).
Common situations: Closing or reloading the Midjourney tab while the CLI is running; VPN/proxy dropping the connection; Midjourney changing the cancel endpoint path so the injected fetch hits a 404 route that redirects; stale page context after long idle sessions.
Related errors
- Midjourney API request failed: ${message}
- Midjourney cancel request failed: HTTP ${result?.status ?? 0
- Midjourney browser-context media fetch failed: ${errorMessag
- Midjourney media download failed: HTTP ${payload?.status ??
- Midjourney reference upload
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/e43aa4cb650f497e.
Report an issue: GitHub.