{"record":{"id":"68155adf601b8faa","repo":"siyuan-note/siyuan","slug":"panic-during-siyuan-storage-get-v","errorCode":null,"errorMessage":"panic during siyuan.storage.get: %v","messagePattern":"panic during siyuan\\.storage\\.get: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/plugin/api_storage.go","lineNumber":174,"sourceCode":"\t\t} else {\n\t\t\targErr = fmt.Errorf(\"path required\")\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\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 []byte, 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.get: %v\", r)\n\t\t\t\t\t}\n\t\t\t\t\tp.worker.Run(func(rt *goja.Runtime) (_ any, _ error) {\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tcontent := rt.NewObject()\n\t\t\t\t\t\tif err = ObjectSetDataMethods(p, rt, content, result); err != nil {\n\t\t\t\t\t\t\treturn nil, err\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\treturn content, nil\n\t\t\t\t\t}, func(rt *goja.Runtime, result any, err error) {\n\t\t\t\t\t\tif lo.IsNil(err) {\n\t\t\t\t\t\t\tif resolveErr := resolve(result); resolveErr != nil {\n\t\t\t\t\t\t\t\tlogging.LogErrorf(\"[plugin:%s] siyuan.storage.get resolve: %v\", p.Name, resolveErr)\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else {","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/plugin/api_storage.go#L156-L192","documentation":"The goroutine that performs the file read for siyuan.storage.get(path) recovered from a Go panic; the panic value is formatted into this message and the Promise is rejected. This is a defensive wrapper around unexpected internal failures during the read or result-marshalling phase, not a normal I/O error (those surface as their own messages).","triggerScenarios":"A panic inside the deferred recovery path itself, in filelock.ReadFile, or while building the result object (ObjectSetDataMethods) for the get call; nil pointer or index-out-of-range bugs in the storage layer triggered by unusual file states.","commonSituations":"Kernel-side bugs or race conditions while reading a file concurrently being replaced; extremely large or unusual files stressing the marshalling path; running a plugin against a kernel build with an internal defect.","solutions":["Catch the rejection and inspect the embedded panic value for the concrete cause","Retry the siyuan.storage.get call once — transient races between write and read often resolve","Ensure the file is not being modified/deleted concurrently by your own plugin (serialize put/get)","Report persistent occurrences with the panic text to the SiYuan kernel maintainers"],"exampleFix":"// before\nconst data = await siyuan.storage.get(\"state.json\");\n// after\nlet data;\ntry {\n  data = await siyuan.storage.get(\"state.json\");\n} catch (e) {\n  console.error(\"storage.get panicked:\", e.message); // inspect wrapped panic\n  data = null; // fall back to defaults\n}","handlingStrategy":"try-catch","validationCode":"if (typeof path !== \"string\") throw new TypeError(\"path must be a string\"); // avoids unrelated failure modes first","typeGuard":"null","tryCatchPattern":"try { const data = await siyuan.storage.get(path); } catch (e) { console.error(\"storage.get panic:\", e.message); return cachedDefaults; }","preventionTips":["Serialize put/get on the same file within your plugin to avoid read/write races","Retry once on transient failures before surfacing the error","Keep plugin data files modest in size and avoid deleting files mid-read","Report persistent panics with the embedded value to SiYuan maintainers"],"tags":["plugins","panic","filesystem","siyuan"],"backgroundTag":"internal-invariant-violation","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"}