yikart/AiToEarn · error · Error

Failed to fetch ${url}: ${response.status}

Error message

Failed to fetch ${url}: ${response.status}

What it means

parseYml in the electron updater fetches a remote YAML update manifest and throws 'Failed to fetch ${url}: ${response.status}' when the HTTP response is not ok. The update-manifest endpoint returned a non-2xx status (404, 403, 500, etc.), so version metadata for win/mac could not be loaded.

Source

Thrown at project/aitoearn-electron/server/src/app.service.ts:15

/*
 * @Author: nevin
 * @Date: 2025-03-01 19:27:26
 * @LastEditTime: 2025-03-19 15:41:06
 * @LastEditors: nevin
 * @Description: 应用
 */
import { Injectable } from '@nestjs/common';
import * as yaml from 'yaml';

async function parseYml(url: string): Promise<any> {
  try {
    const response = await fetch(url);
    if (!response.ok) {
      throw new Error(`Failed to fetch ${url}: ${response.status}`);
    }
    const text = await response.text();
    return yaml.parse(text.replace(/\\/g, ''));
  } catch (error) {
    console.error(`YAML解析失败: ${url}`, error);
    throw error;
  }
}

@Injectable()
export class AppService {
  async getDownUrl() {
    const winYml = 'https://ylzsfile.yikart.cn/att/latest.yml';
    const macYml = 'https://ylzsfile.yikart.cn/att/latest-mac.yml';

    const [winYmlJson, macYmlJson] = await Promise.all([
      parseYml(winYml),
      parseYml(macYml),

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Open the exact URL in a browser/curl to confirm the status code and fix the hosted YML file or URL.
  2. Check update channel configuration (version, channel, provider URL) matches the published artifacts.
  3. Retry if the status is 5xx — it may be a transient server error.
  4. Add a fallback update mirror or cached manifest.

Example fix

// before
const response = await fetch(url);
if (!response.ok) throw new Error(`Failed to fetch ${url}: ${response.status}`);
// after
const response = await fetch(url);
if (!response.ok) {
  if (response.status >= 500 && attempt < 3) return retry(url, attempt + 1);
  throw new Error(`Failed to fetch ${url}: ${response.status}`);
}
Defensive patterns

Strategy: retry

Validate before calling

const head = await fetch(url, { method: 'HEAD' });
if (!head.ok) throw new Error(`更新清单不可用: ${url} -> ${head.status}`);

Try / catch

try {
  const yml = await parseYml(url);
} catch (e) {
  if (e.message.includes('404')) throw new Error('更新清单缺失,请检查发布产物 latest.yml');
  if (e.message.includes('403')) throw new Error('更新清单被拒绝访问,请检查URL签名/权限');
  throw e; // 5xx 可重试
}

Prevention

When it happens

Trigger: fetch(url) returns response.ok === false — the update YML URL points to a missing/renamed file, requires auth, is blocked by CDN/firewall, or the server errors.

Common situations: Latest.yml / latest-mac.yml missing on the release server after a deploy; wrong base URL or channel in update config; CDN geo-blocking; expired signed URLs returning 403.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/a877bcda4c695a42. Report an issue: GitHub.