{"record":{"id":"c89b37db339a141a","repo":"siyuan-note/siyuan","slug":"plugin-file-watcher-is-not-supported-on-mobile","errorCode":null,"errorMessage":"plugin file watcher is not supported on mobile","messagePattern":"plugin file watcher is not supported on mobile","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/plugin/source_watcher.go","lineNumber":38,"sourceCode":"\t\"crypto/sha256\"\n\t\"errors\"\n\t\"os\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"sync\"\n\t\"time\"\n\n\t\"github.com/fsnotify/fsnotify\"\n\t\"github.com/siyuan-note/logging\"\n\t\"github.com/siyuan-note/siyuan/kernel/util\"\n)\n\nconst (\n\tpluginSourceReloadDelay  = 300 * time.Millisecond\n\tpluginSourcePollInterval = time.Second\n)\n\nvar errPluginFileWatchUnsupported = errors.New(\"plugin file watcher is not supported on mobile\")\n\ntype pluginSourceWatchMode uint8\n\nconst (\n\tpluginSourceWatchDisabled pluginSourceWatchMode = iota\n\tpluginSourceWatchEvents\n\tpluginSourceWatchPolling\n)\n\ntype pluginSourceWatchEntry struct {\n\tpath       string\n\tsignature  [sha256.Size]byte\n\tfileState  pluginSourceFileState\n\tlastError  string\n\tverified   bool\n\tgeneration uint64\n\ttimer      *time.Timer\n}","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/plugin/source_watcher.go#L20-L56","documentation":"errPluginFileWatchUnsupported is returned by addStorageWatch and removeStorageWatch when file-system watching is unavailable — specifically on mobile builds, where the plugin source watcher is compiled out. Callers asking the kernel to watch a plugin storage path for changes get this sentinel error instead of a watcher.","triggerScenarios":"Calling KernelPlugin.addStorageWatch(path) or removeStorageWatch(path) on a mobile (Android/iOS/HarmonyOS) build where isPluginFileWatchSupported() returns false; any kernel path that sets up storage watching while running the gomobile-linked kernel.","commonSituations":"Plugin relies on storage file hot-reload during development but is being tested on the mobile app; shared code path invoked on mobile after being written for desktop; CI running mobile build targets exercising watch setup.","solutions":["Guard watch setup with isPluginFileWatchSupported() (or a build/platform check) and skip silently on mobile.","Treat this sentinel error as an expected no-op on mobile: catch it and continue without a watcher.","On desktop, verify the watcher prerequisites (fsnotify support) are met — this error should not occur there.","If hot-reload is required on mobile, use an alternative refresh mechanism (manual reload / kernel push events) instead of fs watching."],"exampleFix":"// before\nif err := p.addStorageWatch(path); err != nil {\n    return err\n}\n// after\nif err := p.addStorageWatch(path); err != nil {\n    if errors.Is(err, errPluginFileWatchUnsupported) {\n        return nil // no fs watching on mobile\n    }\n    return err\n}","handlingStrategy":"fallback","validationCode":"// Go\nif !isPluginFileWatchSupported() {\n    // skip watch setup up-front on mobile\n}","typeGuard":null,"tryCatchPattern":"if err := p.addStorageWatch(path); err != nil && !errors.Is(err, errPluginFileWatchUnsupported) {\n    return err\n}","preventionTips":["Gate watch setup behind isPluginFileWatchSupported() or build tags.","Treat errPluginFileWatchUnsupported as an expected no-op on mobile.","Provide a non-fs fallback refresh path for mobile plugins."],"tags":["mobile","file-watcher","platform-limitation","plugin"],"backgroundTag":"unsupported-platform","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}