{"record":{"id":"02cb78618a3483d9","repo":"hmjz100/LinkSwift","slug":"112","errorCode":"112","errorMessage":"提示：<br/>页面已过期，请刷新后重试~<br/>代码：112","messagePattern":"提示：<br/>页面已过期，请刷新后重试~<br/>代码：112","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"（改）网盘直链下载助手.user.js","lineNumber":5938,"sourceCode":"\t\t\t\t}\r\n\r\n\t\t\t\ttemp.glinks.splice(idx, 1); // 过期删除\r\n\t\t\t\treturn true;\r\n\t\t\t});\r\n\r\n\t\t\tfor (let i = 0; i < pending.length; i += size) {\r\n\t\t\t\t// 当前批次\r\n\t\t\t\tconst batch = pending.slice(i, i + size);\r\n\t\t\t\tconst fsids = JSON.stringify(batch.map(item => item.fs_id));\r\n\r\n\t\t\t\tconst url = new URL(config.$baidu.api.getLink);\r\n\t\t\t\turl.searchParams.set(\"fsids\", fsids);\r\n\t\t\t\turl.searchParams.set(\"access_token\", token);\r\n\r\n\t\t\t\tconst res = await base.get(url, { \"User-Agent\": config.$baidu.api.ua.downloadLink });\r\n\r\n\t\t\t\tif (!res || res.errno !== 0 || !res.list) {\r\n\t\t\t\t\tif (res.errno === 112) throw new Error(\"提示：<br/>页面已过期，请刷新后重试~<br/>代码：\" + res.errno);\r\n\t\t\t\t\tif (res.errno === 9019) {\r\n\t\t\t\t\t\tbase.delValue(\"baidu_access_token\");\r\n\t\t\t\t\t\tthrow new Error(\"提示：<br/>访问令牌已过期，再获取一次吧~<br/>代码：\" + res.errno);\r\n\t\t\t\t\t}\r\n\t\t\t\t\tif (res.errno || res.errmsg) {\r\n\t\t\t\t\t\tbatch.forEach(item => item.dlink = `获取下载地址失败，${(res.errno || res.errmsg) ? \"服务器说：\" + (res.errno && res.errmsg ? res.errno + \" - \" + res.errmsg : (res.errmsg || res.errno)) + \"。\" : \"刷新后再试试吧~\"}`);\r\n\t\t\t\t\t} else {\r\n\t\t\t\t\t\tthrow new Error(\"提示：<br/>获取下载链接失败，刷新网页后再试试吧~\");\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\r\n\t\t\t\tbatch.forEach(_item => {\r\n\t\t\t\t\tconst item = res.list.find(li => li.fs_id == _item.fs_id);\r\n\t\t\t\t\tif (item) {\r\n\t\t\t\t\t\tObject.assign(_item, item);\r\n\t\t\t\t\t\ttemp.glinks.push({ id: _item.fs_id, expires: (Date.now() + 4 * 60 * 60 * 1000), data: item });\r\n\t\t\t\t\t}\r\n\t\t\t\t});\r","sourceCodeStart":5920,"sourceCodeEnd":5956,"githubUrl":"https://github.com/hmjz100/LinkSwift/blob/417ea5e28a3e1a90339710e17356e9fd22b8a34b/（改）网盘直链下载助手.user.js#L5920-L5956","documentation":"Baidu Netdisk's OpenAPI file-list endpoint (fetched via base.get with access_token, 网盘直链下载助手.user.js:5938) returned errno 112. Baidu uses errno 112 to mean the session/page identifier has expired, so the script throws this 'page expired, refresh and retry' error. It is a server-reported staleness code surfaced as a user-facing error.","triggerScenarios":"Calling the Baidu download-link batch API while the `access_token`/page context bound to the request has expired — e.g. the access token was obtained long before the request, or the Baidu page state the token was issued against was invalidated server-side.","commonSituations":"Leaving a Baidu Netdisk tab open for hours then trying to fetch links; the token obtained in one session being reused after Baidu rotated it; server-side session invalidation (logout elsewhere, risk control).","solutions":["Refresh the Baidu Netdisk page to get a fresh page context/token, then retry.","Re-run the script's authorization/token-acquisition flow so a new access_token is stored.","If it recurs quickly, clear the script's stored Baidu value (the script manages `baidu_access_token`) and re-authorize.","Check network/proxy time skew or caching that might replay an old token request."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const token = base.getValue(\"baidu_access_token\");\nif (!token) { /* trigger re-authorization before calling the API */ }","typeGuard":"function isBaiduExpired(res) { return res && res.errno === 112; }","tryCatchPattern":"try {\n  await fetchBaiduDownloadLinks(batch);\n} catch (e) {\n  if (String(e.message).includes(\"代码：112\")) {\n    // prompt user to refresh the Baidu page, then re-acquire token and retry once\n  } else throw e;\n}","preventionTips":["Refresh the Baidu Netdisk page before long batch operations if the tab has been idle for hours.","Re-authorize when the script reports token problems instead of retrying with the stale token.","Avoid reusing tokens across sessions/devices that may invalidate each other.","Treat errno 112 as retryable-after-refresh; clear stored state before retrying."],"tags":["baidu","session-expired","api-error","network"],"backgroundTag":"session-token-expired","analyzedSha":"417ea5e28a3e1a90339710e17356e9fd22b8a34b","analyzedAt":"2026-09-02T18:13:32.837Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T21:17:11.164Z"}