{"record":{"id":"26f88552fca07ee6","repo":"siyuan-note/siyuan","slug":"the-current-kernel-is-in-read-only-mode-storage-p","errorCode":null,"errorMessage":"The current kernel is in read-only mode, storage.put is not allowed","messagePattern":"The current kernel is in read-only mode, storage\\.put is not allowed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/api_storage.go","lineNumber":247,"sourceCode":"\tlo.Must0(storage.Set(\"put\", rt.ToValue(func(call goja.FunctionCall, rt *goja.Runtime) goja.Value {\n\t\tpromise, resolve, reject := rt.NewPromise()\n\n\t\tvar argErr error\n\t\tvar path, content string\n\t\tif len(call.Arguments) < 2 {\n\t\t\targErr = fmt.Errorf(\"path and content required\")\n\t\t} else {\n\t\t\tpath = call.Argument(0).String()\n\t\t\tcontent = call.Argument(1).String()\n\t\t}\n\n\t\trunErr := p.worker.Run(func(rt *goja.Runtime) (result any, err error) {\n\t\t\tif argErr != nil {\n\t\t\t\terr = argErr\n\t\t\t\treturn\n\t\t\t}\n\t\t\tif util.ReadOnly {\n\t\t\t\terr = fmt.Errorf(\"The current kernel is in read-only mode, storage.put is not allowed\")\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tabs, resolveErr := resolvePath(path)\n\t\t\tif resolveErr != nil {\n\t\t\t\terr = resolveErr\n\t\t\t\treturn\n\t\t\t}\n\n\t\t\tgo func() (result any, err error) {\n\t\t\t\tdefer func() {\n\t\t\t\t\tif r := recover(); r != nil {\n\t\t\t\t\t\terr = fmt.Errorf(\"panic during siyuan.storage.put: %v\", r)\n\t\t\t\t\t}\n\n\t\t\t\t\tp.worker.Run(func(rt *goja.Runtime) (_ any, _ error) {\n\t\t\t\t\t\tif lo.IsNil(err) {\n\t\t\t\t\t\t\tif resolveErr := resolve(result); resolveErr != nil {","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/plugin/api_storage.go#L229-L265","documentation":"Rejected when siyuan.storage.put(path, content) is called while the SiYuan kernel is running in read-only mode (util.ReadOnly). Read-only mode blocks all mutating operations to protect data; plugin storage writes are refused even though the path is valid and the plugin itself is loaded.","triggerScenarios":"The kernel was started with a read-only flag or the workspace is in a read-only state (e.g. protected mode) and the plugin calls siyuan.storage.put; automated plugin tasks writing on boot while the user opened the workspace read-only.","commonSituations":"Running SiYuan with the read-only launch option for safe browsing; CI/automation sessions with read-only workspaces; plugins that cache state via storage.put unconditionally on startup.","solutions":["Detect read-only state before writing and degrade gracefully (skip the put, keep state in memory)","Retry the put later when the workspace is reopened in read-write mode","Inform the user that the setting/state could not be persisted because the kernel is read-only","Relaunch SiYuan without the read-only option if persistent writes are required"],"exampleFix":"// before\nawait siyuan.storage.put(\"state.json\", JSON.stringify(state));\n// after\ntry {\n  await siyuan.storage.put(\"state.json\", JSON.stringify(state));\n} catch (e) {\n  if (String(e.message).includes(\"read-only mode\")) {\n    console.warn(\"Kernel is read-only; keeping state in memory only\");\n  } else { throw e; }\n}","handlingStrategy":"try-catch","validationCode":"// probe with a harmless write on init to learn mode\ncanWrite = await siyuan.storage.put(\".probe\", \"1\").then(() => true, () => false);","typeGuard":"null","tryCatchPattern":"try { await siyuan.storage.put(path, content); } catch (e) { if (String(e.message).includes(\"read-only mode\")) { keepInMemoryOnly(); } else { throw e; } }","preventionTips":["Persist plugin state opportunistically, tolerating read-only sessions","Queue writes and flush them when the workspace is next writable","Surface a user-facing notice when a required write is blocked by read-only mode","Avoid unconditional writes on plugin load, which fire during read-only sessions"],"tags":["plugins","read-only","filesystem","siyuan"],"backgroundTag":"read-only-mode-write-blocked","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}