{"record":{"id":"2403acc541c276c6","repo":"yikart/AiToEarn","slug":"error-2403ac","errorCode":null,"errorMessage":"解析后的数据为空","messagePattern":"解析后的数据为空","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"project/aitoearn-electron/electron/plat/douyin/index.ts","lineNumber":2362,"sourceCode":"\n          if (retryCount < maxRetries - 1) {\n            retryCount++;\n            console.log(`等待${retryDelay / 1000}秒后重试...`);\n            await new Promise((resolve) => setTimeout(resolve, retryDelay));\n            continue;\n          }\n\n          throw new Error(\n            '服务器多次返回空数据，请检查网络连接或抖音服务器状态',\n          );\n        }\n\n        try {\n          const result = JSON.parse(responseText);\n\n          if (!result) {\n            console.error(`解析后的数据为空`);\n            throw new Error('解析后的数据为空');\n          }\n\n          return result;\n        } catch (err) {\n          console.error(`解析响应数据失败:`, err);\n          console.error(`导致错误的原始数据:`, responseText);\n          throw new Error(\n            `解析响应数据失败: ${err instanceof Error ? err.message : String(err)}`,\n          );\n        }\n      } catch (error) {\n        if (retryCount < maxRetries - 1) {\n          retryCount++;\n          console.log(\n            `请求失败，${retryDelay / 1000}秒后进行第${retryCount}次重试...`,\n          );\n          await new Promise((resolve) => setTimeout(resolve, retryDelay));\n          continue;","sourceCodeStart":2344,"sourceCodeEnd":2380,"githubUrl":"https://github.com/yikart/AiToEarn/blob/d3aa8bea5b146a8675607cf0144d891aad3e9683/project/aitoearn-electron/electron/plat/douyin/index.ts#L2344-L2380","documentation":"Inside postFormData's JSON-parsing block, if JSON.parse succeeds but the parsed value is falsy (e.g. the body was literally 'null' or '0'), the code logs and throws '解析后的数据为空' (project/aitoearn-electron/electron/plat/douyin/index.ts:2362). Because it is thrown inside the inner try, the outer catch wraps it into '请求失败: 解析后的数据为空' on the last attempt. It means Douyin returned valid JSON that carries no usable payload.","triggerScenarios":"responseText parses successfully but evaluates to null/false/0/'' — e.g. Douyin responding with the literal body 'null' — typically for endpoints hit through postFormData with stale auth or a rejected action.","commonSituations":"Douyin returning 'null' bodies when the session cookie is invalid or the target resource (comment/aweme) no longer exists; risk-control responses that return null JSON instead of an error object; calling after the content was deleted.","solutions":["Refresh the Douyin cookie/session — a null JSON body almost always means the request was not authenticated properly.","Validate that the target resource (comment id, aweme id) still exists before calling the service.","Log/treat the response as a rejected action and retry with backoff; add larger retryOptions if the failure is intermittent.","Capture the raw responseText (it is logged via console.error) to confirm what the server actually returned."],"exampleFix":"// before\nconst result = await douyinService.creatorDianzanOther(cookie, data);\n// after\ntry {\n  const result = await douyinService.creatorDianzanOther(cookie, data);\n} catch (e) {\n  if (String(e.message).includes('解析后的数据为空')) {\n    // refresh cookie / validate resource before retrying\n  }\n  throw e;\n}","handlingStrategy":"validation","validationCode":"function looksLikeDouyinNullBody(text: string): boolean {\n  const t = text.trim();\n  return t === 'null' || t === '0' || t === '';\n}","typeGuard":"function isParsedResult(v: unknown): v is Record<string, unknown> {\n  return typeof v === 'object' && v !== null;\n}","tryCatchPattern":"try {\n  const result = await douyinService.someOp(cookie, data);\n} catch (e) {\n  if (String(e.message).includes('解析后的数据为空')) {\n    await refreshDouyinCookie();\n    // verify the target resource still exists before retrying\n  } else throw e;\n}","preventionTips":["Verify cookies/session validity before batch calls.","Check that target comment/aweme ids still exist before invoking the service.","Enable the library's console.error output to capture the raw response for diagnosis.","Prefer passing explicit retryOptions with backoff for intermittent null bodies."],"tags":["douyin","json-parse","null-response","api"],"backgroundTag":"null-json-response","analyzedSha":"d3aa8bea5b146a8675607cf0144d891aad3e9683","analyzedAt":"2026-08-31T14:19:24.185Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}