Skip to content

Commit 7ec1cf2

Browse files
authored
fix(wasm): Version modules by wasmtime version (#1734)
Compiled modules can't be shared across wasmtime versions. Make sure to include the current version of wasmtime in the module filename.
1 parent b4d7d4f commit 7ec1cf2

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

internal/ext/wasm/wasm.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ import (
2424
"github.com/kyleconroy/sqlc/internal/plugin"
2525
)
2626

27+
// This version must be updated whenever the wasmtime-go dependency is updated
28+
const wasmtimeVersion = `v0.38.1`
29+
2730
func cacheDir() (string, error) {
2831
cache := os.Getenv("SQLCCACHE")
2932
if cache != "" {
@@ -68,7 +71,8 @@ func (r *Runner) loadModule(ctx context.Context, engine *wasmtime.Engine) (*wasm
6871
}
6972

7073
pluginDir := filepath.Join(cache, expected)
71-
modPath := filepath.Join(pluginDir, fmt.Sprintf("plugin_%s_%s.module", runtime.GOOS, runtime.GOARCH))
74+
modName := fmt.Sprintf("plugin_%s_%s_%s.module", runtime.GOOS, runtime.GOARCH, wasmtimeVersion)
75+
modPath := filepath.Join(pluginDir, modName)
7276
_, staterr := os.Stat(modPath)
7377
if staterr == nil {
7478
data, err := os.ReadFile(modPath)

0 commit comments

Comments
 (0)