hmjz100/LinkSwift · error · Error

[光鸭云盘] 获取文件下载 URL 失败

Error message

[光鸭云盘] 获取文件下载 URL 失败

What it means

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.

Source

Thrown at (改)网盘直链下载助手.user.js:8120

				const batchSize = 15;
				let proc = 0;
				$doc.find(".loading-popup .loading-title").html(`链接获取中`);
				$doc.find(".loading-popup .swal2-html-container").html(`<div>正在获取文件对应的下载链接~</div>`);
				for (let i = 0; i < selects.length; i += batchSize) {
					const batch = selects.slice(i, i + batchSize);
					const queue = [];
					batch.forEach((item, localIndex) => {
						const globalIndex = i + localIndex;
						queue.push(this.getFileUrl(item, globalIndex, token)
							.then(val => {
								proc++;
								$doc.find(".loading-popup .swal2-html-container").html(`<div>已获取 ${proc} / ${selects.length} 个链接~</div>`);
								return val;
							}));
					});
					const res = await Promise.all(queue).catch(e => {
						if (e instanceof Error) throw e;
						throw new Error(e?.message || e || "[光鸭云盘] 获取文件下载 URL 失败");
					});
					res.forEach(val => {
						selects[val.index].downloadUrl = val.downloadUrl;
					});
					await base.sleep(1000);
				}
			} else if (temp.page === "share") {
				const token = this.getToken();
				const shareToken = await this.getShareToken(false, token).catch(e => {
					if (e instanceof Error) throw e;
					throw new Error(e?.message || e || "[光鸭云盘] 获取分享令牌失败");
				});
				const batchSize = 15;
				let proc = 0;
				$doc.find(".loading-popup .loading-title").html(`链接获取中`);
				$doc.find(".loading-popup .swal2-html-container").html(`<div>正在获取文件对应的下载链接~</div>`);
				for (let i = 0; i < selects.length; i += batchSize) {
					const batch = selects.slice(i, i + batchSize);

View on GitHub (pinned to 417ea5e28a)

Solutions

  1. Retry the link fetch — transient batch failures often clear on a second attempt.
  2. Reduce selection size / retry in smaller batches to isolate which file fails.
  3. Check browser console/network for the failing per-file API call and its status code.
  4. Ensure you are logged in if the failing task needed credentials.

Example fix

// before
throw new Error(e?.message || e || "[光鸭云盘] 获取文件下载 URL 失败");
// after
const reason = e instanceof Error ? e.message : (typeof e === 'string' ? e : JSON.stringify(e));
throw new Error(`[光鸭云盘] 获取文件下载 URL 失败:${reason}`);
Defensive patterns

Strategy: retry

Type guard

const hasErrorDetail = e => e instanceof Error || e?.message || typeof e === 'string';

Try / catch

try { await driver.getLink(); } catch (e) { if (String(e.message).includes('获取文件下载 URL 失败')) { await sleep(1500); return driver.getLink(); } throw e; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hmjz100/LinkSwift@417ea5e28a (2026-09-02). Data as JSON: /api/errors/77998c715bb00c92. Report an issue: GitHub.