{"record":{"id":"77998c715bb00c92","repo":"hmjz100/LinkSwift","slug":"url-77998c","errorCode":null,"errorMessage":"[光鸭云盘] 获取文件下载 URL 失败","messagePattern":"\\[光鸭云盘\\] 获取文件下载 URL 失败","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"（改）网盘直链下载助手.user.js","lineNumber":8120,"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, token)\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 => {\r\n\t\t\t\t\t\tselects[val.index].downloadUrl = val.downloadUrl;\r\n\t\t\t\t\t});\r\n\t\t\t\t\tawait base.sleep(1000);\r\n\t\t\t\t}\r\n\t\t\t} else if (temp.page === \"share\") {\r\n\t\t\t\tconst token = this.getToken();\r\n\t\t\t\tconst shareToken = await this.getShareToken(false, token).catch(e => {\r\n\t\t\t\t\tif (e instanceof Error) throw e;\r\n\t\t\t\t\tthrow new Error(e?.message || e || \"[光鸭云盘] 获取分享令牌失败\");\r\n\t\t\t\t});\r\n\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","sourceCodeStart":8102,"sourceCodeEnd":8138,"githubUrl":"https://github.com/hmjz100/LinkSwift/blob/417ea5e28a3e1a90339710e17356e9fd22b8a34b/（改）网盘直链下载助手.user.js#L8102-L8138","documentation":"Fallback wrapper in the 'home' page branch of 光鸭云盘 getLink(): when the Promise.all over the batch queue rejects, any non-Error rejection is re-thrown as this generic '[光鸭云盘] 获取文件下载 URL 失败' message. It masks the per-file failure reason because the original thrown value was not an Error instance.","triggerScenarios":"One of the batched per-file URL tasks rejected with a non-Error value (plain string, object, or undefined) — e.g. an inner .catch(() => Promise.reject('...')) or a rejected fetch handled by rejecting with a raw message.","commonSituations":"Backend per-file API returned an unexpected shape and the batch task rejected with a plain object; a batch task threw a string; rate limiting made a task reject without an Error.","solutions":["Retry the link fetch — transient batch failures often clear on a second attempt.","Reduce selection size / retry in smaller batches to isolate which file fails.","Check browser console/network for the failing per-file API call and its status code.","Ensure you are logged in if the failing task needed credentials."],"exampleFix":"// before\nthrow new Error(e?.message || e || \"[光鸭云盘] 获取文件下载 URL 失败\");\n// after\nconst reason = e instanceof Error ? e.message : (typeof e === 'string' ? e : JSON.stringify(e));\nthrow new Error(`[光鸭云盘] 获取文件下载 URL 失败：${reason}`);","handlingStrategy":"retry","validationCode":null,"typeGuard":"const hasErrorDetail = e => e instanceof Error || e?.message || typeof e === 'string';","tryCatchPattern":"try { await driver.getLink(); } catch (e) { if (String(e.message).includes('获取文件下载 URL 失败')) { await sleep(1500); return driver.getLink(); } throw e; }","preventionTips":["Retry with a smaller selection to isolate the failing file","Keep the browser console open to see the real per-file failure","Ensure a stable network and an active login session"],"tags":["userscript","promise-rejection","cloud-drive","batch-download"],"backgroundTag":"download-url-fetch-failed","analyzedSha":"417ea5e28a3e1a90339710e17356e9fd22b8a34b","analyzedAt":"2026-09-02T18:13:32.837Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}