Skip to content

fix: add missing WASM compilation cache cleanup in run()#8424

Merged
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-fix-run-methods
Jul 1, 2026
Merged

fix: add missing WASM compilation cache cleanup in run()#8424
lpcox merged 2 commits into
mainfrom
copilot/duplicate-code-fix-run-methods

Conversation

Copilot AI commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

run() in root.go configured the wazero disk-backed compilation cache but never called guard.CloseGlobalCompilationCache() on shutdown, unlike runProxy() which defers the cleanup correctly. For disk-backed caches this risks leaving transient state unflushed.

Changes

  • internal/cmd/root.go: Add guard import and defer CloseGlobalCompilationCache after a successful configureWasmCompilationCache call, mirroring the existing pattern in proxy.go:
cleanupCtx := context.WithoutCancel(ctx)
defer func() {
    if err := guard.CloseGlobalCompilationCache(cleanupCtx); err != nil {
        logger.LogError("shutdown", "Failed to close WASM compilation cache: %v", err)
    }
}()

Copilot AI changed the title [WIP] Fix duplicate code pattern in run() and runProxy() methods fix: add missing WASM compilation cache cleanup in run() Jul 1, 2026
GitHub Advanced Security started work on behalf of lpcox July 1, 2026 15:05 View session
Copilot finished work on behalf of lpcox July 1, 2026 15:05
Copilot AI requested a review from lpcox July 1, 2026 15:05
GitHub Advanced Security finished work on behalf of lpcox July 1, 2026 15:05
@lpcox
lpcox marked this pull request as ready for review July 1, 2026 15:27
Copilot AI review requested due to automatic review settings July 1, 2026 15:27

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

Ensures the gateway’s main run() path properly releases wazero disk-backed WASM compilation cache resources on shutdown, aligning lifecycle management with the existing runProxy() behavior and reducing risk of unflushed transient cache state.

Changes:

  • Add internal/guard import to internal/cmd/root.go.
  • After a successful configureWasmCompilationCache(...), defer guard.CloseGlobalCompilationCache(context.WithoutCancel(ctx)) and log on close failure.
Show a summary per file
File Description
internal/cmd/root.go Adds deferred shutdown cleanup for the global WASM compilation cache in the main gateway run() path.

Review details

Tip

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

  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Low

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.

[duplicate-code] Duplicate Code Pattern: Structural divergence between run() and runProxy() startup routines

3 participants