navidrome/navidrome · error
creating instance: %w
Error message
creating instance: %w
What it means
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.
Source
Thrown at plugins/manager_loader.go:425
runtimeConfig := wazero.NewRuntimeConfig().
WithCompilationCache(m.cache).
WithCloseOnContextDone(true)
extismConfig := extism.PluginConfig{
EnableWasi: true,
RuntimeConfig: runtimeConfig,
EnableHttpResponseHeaders: true,
}
compiled, err := extism.NewCompiledPlugin(ctx, pluginManifest, extismConfig, hostFunctions)
if err != nil {
return fmt.Errorf("compiling plugin: %w", err)
}
// Create instance to detect capabilities
instance, err := compiled.Instance(ctx, instanceConfig(fsConfig))
if err != nil {
compiled.Close(ctx)
return fmt.Errorf("creating instance: %w", err)
}
instance.SetLogger(extismLogger(p.ID))
capabilities := detectCapabilities(instance)
instance.Close(ctx)
// Validate manifest against detected capabilities
if err := ValidateWithCapabilities(pkg.Manifest, capabilities); err != nil {
compiled.Close(ctx)
return fmt.Errorf("manifest validation: %w", err)
}
loadedPlugin := &plugin{
name: p.ID,
path: p.Path,
manifest: pkg.Manifest,
compiled: compiled,
capabilities: capabilities,
closers: closers,View on GitHub (pinned to 4ed7494a32)
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
Example fix
// before
os.MkdirAll(getHostStoragePath(p.ID), 0o755) // missing before EnablePlugin
_, _ = manager.EnablePlugin(ctx, id) // creating instance: mount failed
// after
if err := os.MkdirAll(getHostStoragePath(id), 0o755); err != nil { return err }
return manager.EnablePlugin(ctx, id) Defensive patterns
Strategy: try-catch
Validate before calling
// ensure all mount host paths exist before loading
for _, dir := range mountHostPaths(p) {
if err := os.MkdirAll(dir, 0o755); err != nil { return err }
} Try / catch
if err := manager.EnablePlugin(ctx, id); err != nil {
if strings.Contains(err.Error(), "creating instance") {
if strings.Contains(err.Error(), "import") {
return rebuildPluginWithCurrentPDK(id)
}
return fixMountPaths(id) // create missing storage/library dirs
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- opening package: %w
- creating %s service: %w
- compiling plugin: %w
- package missing plugin.wasm
- parsing plugin users: %w
AI-assisted analysis of navidrome/navidrome@4ed7494a32 (2026-09-01).
Data as JSON: /api/errors/a9a8e99fe5ebe8f0.
Report an issue: GitHub.