{"record":{"id":"17bc4fbc3c6ef1d0","repo":"hmjz100/LinkSwift","slug":"url-17bc4f","errorCode":null,"errorMessage":"[中国移动云盘] 获取文件 URL 失败","messagePattern":"\\[中国移动云盘\\] 获取文件 URL 失败","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"（改）网盘直链下载助手.user.js","lineNumber":7065,"sourceCode":"\t\t\t\tconst batchSize = 15;\r\n\t\t\t\tlet proc = 0;\r\n\t\t\t\t$doc.find(\".loading-popup .loading-title\").html(`链接获取中`);\r\n\t\t\t\t$doc.find(\".loading-popup .swal2-html-container\").html(`<div>正在获取文件对应的下载链接~</div>`);\r\n\t\t\t\tfor (let i = 0; i < selects.length; i += batchSize) {\r\n\t\t\t\t\tconst batch = selects.slice(i, i + batchSize);\r\n\t\t\t\t\tconst queue = [];\r\n\t\t\t\t\tbatch.forEach((item, localIndex) => {\r\n\t\t\t\t\t\tconst globalIndex = i + localIndex;\r\n\t\t\t\t\t\tqueue.push(this.getFileUrl(item, globalIndex)\r\n\t\t\t\t\t\t\t.then(val => {\r\n\t\t\t\t\t\t\t\tproc++;\r\n\t\t\t\t\t\t\t\t$doc.find(\".loading-popup .swal2-html-container\").html(`<div>已获取 ${proc} / ${selects.length} 个链接~</div>`);\r\n\t\t\t\t\t\t\t\treturn val;\r\n\t\t\t\t\t\t\t}));\r\n\t\t\t\t\t});\r\n\t\t\t\t\tconst res = await Promise.all(queue).catch(e => {\r\n\t\t\t\t\t\tif (e instanceof Error) throw e;\r\n\t\t\t\t\t\tthrow new Error(e?.message || e || \"[中国移动云盘] 获取文件 URL 失败\");\r\n\t\t\t\t\t});\r\n\t\t\t\t\tres.forEach(val => (selects[val.index].downloadUrl = val.downloadUrl));\r\n\t\t\t\t\tawait base.sleep(1000);\r\n\t\t\t\t}\r\n\t\t\t} else {\r\n\t\t\t\tthrow new Error(\"提示：<br/>页面错误~\");\r\n\t\t\t}\r\n\t\t\ttemp.links = [selects, {\r\n\t\t\t\tisFolder: v => (v.dirEtag || v.caName),\r\n\t\t\t\tgetFileName: v => (v.contentName || v.coName),\r\n\t\t\t\tgetFileSize: v => (v.contentSize || v.coSize),\r\n\t\t\t\tgetFileLink: v => v.downloadUrl,\r\n\t\t\t\ttooltip: config.$mcloud.dom\r\n\t\t\t}];\r\n\t\t\tbase.showMainDialog(config.base.dom.button[temp.mode].title, base.generateDOM(temp.links), config.base.dom.button[temp.mode].footer);\r\n\t\t},\r\n\t\tgetSelectedList() {\r\n\t\t\ttry {\r","sourceCodeStart":7047,"sourceCodeEnd":7083,"githubUrl":"https://github.com/hmjz100/LinkSwift/blob/417ea5e28a3e1a90339710e17356e9fd22b8a34b/（改）网盘直链下载助手.user.js#L7047-L7083","documentation":"Fallback error in the China Mobile Cloud Drive getLink(): after Promise.all over the batch queue rejects, non-Error rejection values are converted into this message. It means one of the per-file URL fetch tasks failed without throwing a proper Error (e.g. it rejected with a string or object), and even its message field was empty/absent.","triggerScenarios":"Any batch task inside the queue rejects with a non-Error value whose ?message is falsy — e.g. a promise rejection with undefined, an empty string, or an object without a message property, caught at line 7065.","commonSituations":"The cloud API returned a malformed/empty error body that the per-file handler rejected with raw; a network failure produced a rejection without message; concurrency limit or rate limiting caused silent task failure.","solutions":["Refresh the page and retry; failures are often transient network/API issues.","Inspect the per-file fetch logic: log the original rejection value before it reaches this catch to see the real cause.","Reduce batch size (currently 15) or add retry/delay to avoid rate limiting from 中国移动云盘.","Ensure each task throws new Error(...) with a message so errors surface with real causes instead of this fallback."],"exampleFix":"// before\ntasks.push(fetchFileUrl(item).catch(e => { throw e?.message || e; }));\n\n// after\ntasks.push(fetchFileUrl(item).catch(e => {\n  throw new Error('[中国移动云盘] 获取文件 URL 失败: ' + (e?.message ?? String(e)));\n}));","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isRealError(e) {\n  return e instanceof Error;\n}","tryCatchPattern":"try {\n  await Promise.all(queue);\n} catch (e) {\n  console.error('原始失败原因:', e);\n  if (e instanceof Error) throw e;\n  throw new Error('[中国移动云盘] 获取文件 URL 失败: ' + String(e));\n}","preventionTips":["Make per-file tasks always throw new Error(...) with a descriptive message.","Log rejection values in the per-task catch before rethrowing.","Lower batch size / add delays to avoid API rate limiting.","Retry transient failures once before failing the whole batch."],"tags":["userscript","china-mobile-cloud","network","promise-rejection"],"backgroundTag":"unhandled-promise-rejection","analyzedSha":"417ea5e28a3e1a90339710e17356e9fd22b8a34b","analyzedAt":"2026-09-02T18:13:32.837Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}