{"record":{"id":"d75cef11dcb9f158","repo":"maotoumao/MusicFree","slug":"toast-failtoupdateplugin","errorCode":null,"errorMessage":"toast.failToUpdatePlugin","messagePattern":"toast\\.failToUpdatePlugin","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/pages/setting/settingTypes/pluginSetting/components/pluginItem.tsx","lineNumber":49,"sourceCode":"function _PluginItem(props: IPluginItemProps) {\r\n    const { plugin } = props;\r\n    const colors = useColors();\r\n    const enabled = usePluginEnabled(plugin);\r\n    const { t } = useI18N();\r\n    const rerender = useRerender();\r\n\r\n    const alternativePluginName = pluginManager.getAlternativePluginName(plugin);\r\n\r\n    const options: IOption[] = [\r\n        {\r\n            title: t(\"pluginSetting.pluginItem.options.updatePlugin\"),\r\n            icon: \"arrow-path\",\r\n            async onPress() {\r\n                try {\r\n                    await pluginManager.updatePlugin(plugin);\r\n                    Toast.success(t(\"toast.pluginUpdateSuccess\"));\r\n                } catch (e: any) {\r\n                    Toast.warn(e?.message ?? t(\"toast.failToUpdatePlugin\"));\r\n                }\r\n            },\r\n            show: !!plugin.instance.srcUrl,\r\n        },\r\n        {\r\n            title: t(\"pluginSetting.pluginItem.options.sharePlugin\"),\r\n            icon: \"share\",\r\n            async onPress() {\r\n                try {\r\n                    Clipboard.setString(plugin.instance.srcUrl!);\r\n                    Toast.success(t(\"toast.copiedToClipboard\"));\r\n                } catch (e: any) {\r\n                    Toast.warn(e?.message ?? t(\"toast.failToSharePlugin\"));\r\n                }\r\n            },\r\n            show: !!plugin.instance.srcUrl,\r\n        },\r\n        {\r","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/maotoumao/MusicFree/blob/d118b18b3d0c904400f7eea7bf99c0ceec6c1aee/src/pages/setting/settingTypes/pluginSetting/components/pluginItem.tsx#L31-L67","documentation":"This fallback toast is displayed when `pluginManager.updatePlugin(plugin)` throws during the 'Update plugin' option. The handler prefers the thrown error's own `message` and falls back to the generic 'failToUpdatePlugin' i18n string when the error carries no message. Update failures typically come from fetching the remote plugin source (network errors, 404s) or from the updated plugin failing to parse/validate.","triggerScenarios":"Selecting the update option on a plugin whose `instance.srcUrl` exists, and `await pluginManager.updatePlugin(plugin)` rejects — e.g. the srcUrl is unreachable, the download fails, the response is not a valid plugin module, or a version-incompatibility check fails inside the plugin manager.","commonSituations":"Plugin author deleted or moved the raw source URL (404); device offline or behind a captive portal/GFW needing proxy; GitHub raw access rate-limited; the remote script has a syntax error or uses APIs incompatible with the current app version; storage failure while persisting the updated plugin.","solutions":["Read the surfaced `e.message` toast: if it mentions network/HTTP, verify the plugin's srcUrl is reachable in a browser and fix or re-add the plugin with a valid URL.","Check device connectivity or configure a proxy if the source host (e.g. raw.githubusercontent.com) is blocked.","If the error is parse/version related, update the app itself or install a plugin version compatible with the current app version.","As a workaround, uninstall the plugin and re-install it from a fresh, known-good source URL instead of updating in place."],"exampleFix":"null","handlingStrategy":"try-catch","validationCode":"const srcUrl = plugin.instance.srcUrl;\nif (!srcUrl) {\n    Toast.warn(t(\"toast.failToUpdatePlugin\"));\n    return;\n}\nconst reachable = await fetch(srcUrl, { method: \"HEAD\" }).then(r => r.ok).catch(() => false);\nif (!reachable) {\n    Toast.warn(t(\"toast.failToUpdatePlugin\"));\n    return;\n}","typeGuard":"function hasSrcUrl(p: Plugin): p is Plugin & { instance: { srcUrl: string } } {\n    return typeof p.instance.srcUrl === \"string\" && p.instance.srcUrl.length > 0;\n}","tryCatchPattern":"try {\n    await pluginManager.updatePlugin(plugin);\n    Toast.success(t(\"toast.pluginUpdateSuccess\"));\n} catch (e: any) {\n    Toast.warn(e?.message ?? t(\"toast.failToUpdatePlugin\"));\n}","preventionTips":["Ensure the plugin's srcUrl points to a stable, reachable raw source (avoid rate-limited hosts).","Check connectivity/proxy settings before updating plugins behind restricted networks.","Keep the app updated so plugin version-compatibility checks pass.","Prefer re-installing from a known-good URL when in-place updates repeatedly fail."],"tags":["network","plugin-update","fetch","i18n"],"backgroundTag":"plugin-update-failed","analyzedSha":"d118b18b3d0c904400f7eea7bf99c0ceec6c1aee","analyzedAt":"2026-08-30T11:49:12.932Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}