Skip to content

Upgrade wazero to v1.12.0 and harden WASM compilation cache shutdown#7793

Merged
lpcox merged 3 commits into
mainfrom
copilot/go-fan-review-tetratelabs-wazero
Jun 19, 2026
Merged

Upgrade wazero to v1.12.0 and harden WASM compilation cache shutdown#7793
lpcox merged 3 commits into
mainfrom
copilot/go-fan-review-tetratelabs-wazero

Conversation

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

This updates the gateway’s in-process WASM runtime from wazero v1.11.0 to v1.12.0 and re-verifies the trap-detection assumption called out in the guard code. It also closes a small lifecycle gap in the shared compilation cache by clearing the global reference before close.

  • Dependency update

    • Bumps github.com/tetratelabs/wazero from v1.11.0 to v1.12.0
    • Refreshes module checksums in go.sum
  • Compilation cache shutdown safety

    • Updates CloseGlobalCompilationCache to set globalCompilationCache = nil while holding the mutex, before closing the cache
    • Prevents a stale global reference from remaining reachable across repeated or unusual shutdown paths
  • Trap handling verification

    • Updates the version-specific comment in wasm_parse.go to reflect verification against wazero v1.12.0
    • Adds a regression test that triggers a real WASM trap and asserts the emitted error still contains the wasm error: prefix used by isWasmTrap
  • Lifecycle regression coverage

    • Adds focused tests for global cache close behavior:
      • shared cache is nilled on close
      • repeated close is effectively idempotent
      • nil state is preserved even when cache close returns an error
func CloseGlobalCompilationCache(ctx context.Context) error {
	globalCompilationCacheMu.Lock()
	cache := globalCompilationCache
	globalCompilationCache = nil
	globalCompilationCacheMu.Unlock()

	if cache == nil {
		return nil
	}
	return cache.Close(ctx)
}

GitHub Advanced Security started work on behalf of lpcox June 19, 2026 15:34 View session
GitHub Advanced Security finished work on behalf of lpcox June 19, 2026 15:35
GitHub Advanced Security started work on behalf of lpcox June 19, 2026 15:40 View session
Copilot AI changed the title [WIP] Review Go module tetratelabs/wazero for usage in gh-aw Upgrade wazero to v1.12.0 and harden WASM compilation cache shutdown Jun 19, 2026
Copilot finished work on behalf of lpcox June 19, 2026 15:40
Copilot AI requested a review from lpcox June 19, 2026 15:40
GitHub Advanced Security finished work on behalf of lpcox June 19, 2026 15:41
@lpcox lpcox marked this pull request as ready for review June 19, 2026 15:45
Copilot AI review requested due to automatic review settings June 19, 2026 15:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR upgrades the in-process WASM runtime dependency (wazero) to v1.12.0 and tightens the lifecycle behavior of the shared WASM compilation cache by clearing the global reference before closing. It also adds regression tests to ensure the trap-detection heuristic ("wasm error:" prefix) and cache shutdown behavior remain stable across the upgrade.

Changes:

  • Bump github.com/tetratelabs/wazero from v1.11.0v1.12.0 (and refresh go.sum).
  • Harden CloseGlobalCompilationCache by setting globalCompilationCache = nil under lock before closing.
  • Add targeted tests for (a) real wazero trap prefix behavior and (b) global cache close idempotence / nil-on-error semantics; update version-verified comment.
Show a summary per file
File Description
internal/guard/wasm.go Clears the global compilation cache reference under mutex prior to closing it.
internal/guard/wasm_test.go Adds trap-prefix regression coverage and new shutdown/idempotence tests for the global compilation cache.
internal/guard/wasm_parse.go Updates the version-verified comment for the "wasm error:" trap fallback to v1.12.0.
go.mod Updates wazero dependency version to v1.12.0.
go.sum Updates module checksums for the wazero version bump.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 4/5 changed files
  • Comments generated: 1

Comment thread internal/guard/wasm.go
Comment on lines 124 to +128
func CloseGlobalCompilationCache(ctx context.Context) error {
logWasm.Print("Closing global compilation cache")
globalCompilationCacheMu.Lock()
cache := globalCompilationCache
globalCompilationCache = nil
@lpcox

lpcox commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

@copilot address review feedback

GitHub Advanced Security started work on behalf of lpcox June 19, 2026 16:25 View session

Copilot AI commented Jun 19, 2026

Copy link
Copy Markdown
Contributor Author

@copilot address review feedback

Updated in commit 6ae9005. I aligned the CloseGlobalCompilationCache doc comment with current behavior: repeated calls are now documented as no-ops after the global cache is cleared, while retaining the warning that concurrent use and closing while guards are active are unsafe.

Copilot finished work on behalf of lpcox June 19, 2026 16:26
GitHub Advanced Security finished work on behalf of lpcox June 19, 2026 16:27
@lpcox lpcox merged commit 5b0d713 into main Jun 19, 2026
27 checks passed
@lpcox lpcox deleted the copilot/go-fan-review-tetratelabs-wazero branch June 19, 2026 21:04
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.

3 participants