Skip to content

Commit ab235ec

Browse files
CopilotMossaka
andcommitted
Fix memory resource limiter implementation using correct Wasmtime API
Co-authored-by: Mossaka <5447827+Mossaka@users.noreply.github.com>
1 parent 4109907 commit ab235ec

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
5555
- Spell check, link checker, and unused dependency checker to CI workflow ([#116](https://github.com/microsoft/wassette/pull/116))
5656
- Kubernetes-style resource limits in policy specification with `resources.limits` section supporting CPU ("500m", "1") and memory ("512Mi", "1Gi") formats ([#166](https://github.com/microsoft/wassette/pull/166))
5757

58+
### Fixed
59+
- Memory resource limiter implementation by properly applying limits to Wasmtime store using the correct `limiter()` API ([#171](https://github.com/microsoft/wassette/pull/171))
60+
5861
### Changed
5962
- CLI now supports both server mode (`wassette serve`) and direct management mode for component operations
6063
- Component load/unload operations can now work independently without requiring a running MCP server

crates/wassette/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,14 @@ impl LifecycleManager {
485485

486486
let mut store = Store::new(self.engine.as_ref(), state);
487487

488-
// Apply memory limits if configured in the policy
489-
if let Some(limiter) = resource_limiter {
490-
store.set_limiter(limiter);
488+
// Apply memory limits if configured in the policy by setting up a limiter closure
489+
// that extracts the resource limiter from the WasiState
490+
if resource_limiter.is_some() {
491+
store.limiter(|state: &mut WassetteWasiState<WasiState>| {
492+
// Extract the resource limiter from the inner state
493+
// We know it exists because we checked above
494+
state.inner.resource_limiter.as_mut().unwrap()
495+
});
491496
}
492497

493498
let instance = component

0 commit comments

Comments
 (0)