yikart/AiToEarn · error · Error

服务器多次返回空数据,请检查网络连接或抖音服务器状态

Error message

服务器多次返回空数据,请检查网络连接或抖音服务器状态

What it means

This is thrown by DouyinService's private postFormData helper (project/aitoearn-electron/electron/plat/douyin/index.ts:2352) after the response body from a creator.douyin.com form-data POST came back empty (null/whitespace-only) on every attempt. The helper retries up to maxRetries (default 3) with retryDelay (default 2000ms) between attempts, and only throws this once the retry budget is exhausted. It signals that Douyin's server (or an intervening network/proxy layer) is accepting the request but returning no body.

Source

Thrown at project/aitoearn-electron/electron/plat/douyin/index.ts:2352

          throw new Error(`服务器返回错误状态码: ${response.status}`);
        }

        const responseText = await response.text();

        // 检查响应数据是否为空
        if (!responseText || responseText.trim() === '') {
          console.error(
            `响应数据为空,尝试次数: ${retryCount + 1}/${maxRetries}`,
          );

          if (retryCount < maxRetries - 1) {
            retryCount++;
            console.log(`等待${retryDelay / 1000}秒后重试...`);
            await new Promise((resolve) => setTimeout(resolve, retryDelay));
            continue;
          }

          throw new Error(
            '服务器多次返回空数据,请检查网络连接或抖音服务器状态',
          );
        }

        try {
          const result = JSON.parse(responseText);

          if (!result) {
            console.error(`解析后的数据为空`);
            throw new Error('解析后的数据为空');
          }

          return result;
        } catch (err) {
          console.error(`解析响应数据失败:`, err);
          console.error(`导致错误的原始数据:`, responseText);
          throw new Error(
            `解析响应数据失败: ${err instanceof Error ? err.message : String(err)}`,

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Check and refresh the Douyin account cookie passed to the service — re-login and rebuild the cookie array, since invalid sessions commonly yield empty bodies.
  2. Verify general network connectivity from the Electron machine (curl the endpoint URL) and check any proxy/VPN settings.
  3. Retry later or reduce call frequency — Douyin risk control may throttle frequent automated calls; add larger retryOptions.retryDelay or maxRetries when calling the service.
  4. Check Douyin creator platform server status; if the platform itself is degraded, wait for recovery.

Example fix

// before
await douyinService.creatorDianzanOther(cookie, data);
// after
if (!cookie || cookie.length === 0) {
  throw new Error('Douyin cookie is empty, please re-login');
}
await douyinService.creatorDianzanOther(cookie, data, { maxRetries: 5, retryDelay: 3000 });
Defensive patterns

Strategy: retry

Validate before calling

if (!cookie || cookie.length === 0) throw new Error('Douyin cookie missing, re-login required');
const netOk = await fetch('https://creator.douyin.com', { method: 'HEAD' }).then(r => r.ok).catch(() => false);
if (!netOk) throw new Error('No connectivity to creator.douyin.com');

Type guard

function isNonEmptyBody(text: unknown): text is string {
  return typeof text === 'string' && text.trim().length > 0;
}

Try / catch

try {
  const result = await douyinService.someOp(cookie, data);
} catch (e) {
  if (String(e.message).includes('服务器多次返回空数据')) {
    await refreshDouyinCookie();
    // retry once with longer delay, or surface a user-facing 'check network / Douyin status' message
  } else throw e;
}

Prevention

When it happens

Trigger: Any DouyinService method that routes through postFormData (e.g. creatorDianzanOther, comment reply/post operations) when response.text() returns '' or whitespace-only on all maxRetries consecutive attempts against creator.douyin.com endpoints.

Common situations: Expired or invalid Douyin login cookies causing the server to respond with an empty 200 body; Douyin rate-limiting or risk-control silently dropping the response; transient network/proxy failures that truncate the response; Douyin server-side incidents; firewall or VPN interference with the request.

Related errors


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