{"record":{"id":"a9a8e99fe5ebe8f0","repo":"navidrome/navidrome","slug":"creating-instance-w","errorCode":null,"errorMessage":"creating instance: %w","messagePattern":"creating instance: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugins/manager_loader.go","lineNumber":425,"sourceCode":"\truntimeConfig := wazero.NewRuntimeConfig().\n\t\tWithCompilationCache(m.cache).\n\t\tWithCloseOnContextDone(true)\n\n\textismConfig := extism.PluginConfig{\n\t\tEnableWasi:                true,\n\t\tRuntimeConfig:             runtimeConfig,\n\t\tEnableHttpResponseHeaders: true,\n\t}\n\tcompiled, err := extism.NewCompiledPlugin(ctx, pluginManifest, extismConfig, hostFunctions)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"compiling plugin: %w\", err)\n\t}\n\n\t// Create instance to detect capabilities\n\tinstance, err := compiled.Instance(ctx, instanceConfig(fsConfig))\n\tif err != nil {\n\t\tcompiled.Close(ctx)\n\t\treturn fmt.Errorf(\"creating instance: %w\", err)\n\t}\n\tinstance.SetLogger(extismLogger(p.ID))\n\tcapabilities := detectCapabilities(instance)\n\tinstance.Close(ctx)\n\n\t// Validate manifest against detected capabilities\n\tif err := ValidateWithCapabilities(pkg.Manifest, capabilities); err != nil {\n\t\tcompiled.Close(ctx)\n\t\treturn fmt.Errorf(\"manifest validation: %w\", err)\n\t}\n\n\tloadedPlugin := &plugin{\n\t\tname:           p.ID,\n\t\tpath:           p.Path,\n\t\tmanifest:       pkg.Manifest,\n\t\tcompiled:       compiled,\n\t\tcapabilities:   capabilities,\n\t\tclosers:        closers,","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/navidrome/navidrome/blob/4ed7494a3293a9e9e647897ebfb9be327efd981b/plugins/manager_loader.go#L407-L443","documentation":"After successful compilation, the loader instantiates the plugin (compiled.Instance) with a filesystem config to probe its capabilities, and instantiation failed. Instantiation runs the module's start/imports wiring, so missing imports, bad FS config, or WASI failures surface here even though compilation succeeded. The compiled plugin is closed before returning to avoid leaks.","triggerScenarios":"Module has imports not satisfied by the provided host functions/WASI; instanceConfig(fsConfig) references host paths that don't exist or can't be mounted (e.g. missing plugin storage dir or library mounts); context canceled during instantiation; WASI startup (stdio, args) fails.","commonSituations":"Plugin storage directory getHostStoragePath(p.ID) was never created so the mount fails; library mount host paths deleted after libraries were removed; plugin imports a newer Extism PDK function the host doesn't provide; request context canceled (client disconnect) mid-load.","solutions":["Check the wrapped inner error: 'missing import' → rebuild plugin against the host's PDK/host-function set","Ensure mounted host paths exist before loading (create plugin storage dir, verify library paths)","Re-enable with a fresh/background context so cancellation doesn't abort instantiation","If mounts are optional at probe time, repackage the plugin without the filesystem permission"],"exampleFix":"// before\nos.MkdirAll(getHostStoragePath(p.ID), 0o755) // missing before EnablePlugin\n_, _ = manager.EnablePlugin(ctx, id) // creating instance: mount failed\n// after\nif err := os.MkdirAll(getHostStoragePath(id), 0o755); err != nil { return err }\nreturn manager.EnablePlugin(ctx, id)","handlingStrategy":"try-catch","validationCode":"// ensure all mount host paths exist before loading\nfor _, dir := range mountHostPaths(p) {\n    if err := os.MkdirAll(dir, 0o755); err != nil { return err }\n}","typeGuard":null,"tryCatchPattern":"if err := manager.EnablePlugin(ctx, id); err != nil {\n    if strings.Contains(err.Error(), \"creating instance\") {\n        if strings.Contains(err.Error(), \"import\") {\n            return rebuildPluginWithCurrentPDK(id)\n        }\n        return fixMountPaths(id) // create missing storage/library dirs\n    }\n    return err\n}","preventionTips":["Pre-create plugin storage and library directories before enabling","Build plugins against the same PDK version the host provides","Use background contexts for load operations so client disconnects can't cancel instantiation","Keep the wrapped inner error in logs — it distinguishes import vs mount failures"],"tags":["go","wasm","extism","plugins"],"backgroundTag":"wasm-instantiation-failed","analyzedSha":"4ed7494a3293a9e9e647897ebfb9be327efd981b","analyzedAt":"2026-09-01T05:03:05.018Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}