Skip to content

fix: do not initialize old dprint-plugin-gofumpt versions twice - #1308

Merged
dsherret merged 1 commit into
mainfrom
fix-gofumpt-double-initialize
Oct 7, 2026
Merged

dsherret merged 1 commit into
mainfrom
fix-gofumpt-double-initialize

Conversation

@dsherret

@dsherret dsherret commented Oct 7, 2026

Copy link
Copy Markdown
Member

Closes #1306

dprint 0.61.0 started calling _initialize on Wasm plugins that export it (#1303), per the WASI reactor convention. dprint-plugin-gofumpt before 0.0.19 runs _initialize as its Wasm start function while still exporting it, so it got initialized twice and trapped with unreachable.

This hardcodes an exception: plugins named dprint-plugin-gofumpt with a version below 0.0.19 no longer get the host _initialize call.

  • When loading from the cache, the plugin info is already known, so the module is flagged up front.
  • When compiling for the first time, the name and version aren't known until the plugin loads. If loading fails and the module exports _initialize, it retries once without calling it and accepts the result only when the plugin turns out to be an old gofumpt. Otherwise the original error is returned.

Tested manually against the real gofumpt 0.0.18 and 0.0.19 plugins with a fresh cache (first compile and cached load).

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The compilation fallback needs automated integration coverage for the reported regression and rejection paths.

1 open finding
What changed in this PR

Adds compatibility for gofumpt versions before 0.0.19 that initialize themselves during Wasm startup.

Changes:

  • Skips duplicate _initialize calls for affected versions.
  • Retries first-time compilation to discover plugin identity.
  • Adds unit coverage for initialization skipping and version detection.
File Description
plugin.rs Applies compatibility behavior to cached plugins.
load_instance.rs Adds initialization controls and unit tests.
compile.rs Adds first-compilation fallback logic.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

};

// load the plugin and get the info
let plugin_info = match get_plugin_info(&module) {
@dsherret
dsherret merged commit d285a3a into main Oct 7, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dprint 0.61.0 no longer loads dprint-plugin-gofumpt

2 participants