Skip to content

Include module name in Wasm trap message #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/handler_loader/compiler.rs
Original file line number Diff line number Diff line change
@@ -17,9 +17,10 @@ pub fn compile(
uncompiled_handlers: LoadedHandlerConfiguration,
compilation_settings: WasmCompilationSettings,
) -> anyhow::Result<WasmHandlerConfiguration> {
uncompiled_handlers.compile_modules(|module_bytes| {
uncompiled_handlers.compile_modules(|module_bytes, module_name| {
crate::wasm_module::WasmModuleSource::from_module_bytes(
module_bytes,
module_name,
&compilation_settings.cache_config_path,
)
})
@@ -28,12 +29,12 @@ pub fn compile(
impl LoadedHandlerConfiguration {
pub fn compile_modules(
self,
compile: impl Fn(std::sync::Arc<Vec<u8>>) -> anyhow::Result<WasmModuleSource>,
compile: impl Fn(std::sync::Arc<Vec<u8>>, &str) -> anyhow::Result<WasmModuleSource>,
) -> anyhow::Result<WasmHandlerConfiguration> {
let result: anyhow::Result<Vec<WasmHandlerConfigurationEntry>> = self
.entries
.into_iter()
.map(|e| e.compile_module(|m| compile(m)))
.map(|e| e.compile_module(|m, n| compile(m, n)))
.collect();
Ok(WasmHandlerConfiguration { entries: result? })
}
@@ -42,9 +43,9 @@ impl LoadedHandlerConfiguration {
impl LoadedHandlerConfigurationEntry {
pub fn compile_module(
self,
compile: impl Fn(std::sync::Arc<Vec<u8>>) -> anyhow::Result<WasmModuleSource>,
compile: impl Fn(std::sync::Arc<Vec<u8>>, &str) -> anyhow::Result<WasmModuleSource>,
) -> anyhow::Result<WasmHandlerConfigurationEntry> {
let compiled_module = compile(self.module)
let compiled_module = compile(self.module, &self.info.name)
.with_context(|| format!("Error compiling Wasm module {}", &self.info.name))?;
Ok(WasmHandlerConfigurationEntry {
info: self.info,
3 changes: 2 additions & 1 deletion src/wasm_module.rs
Original file line number Diff line number Diff line change
@@ -36,10 +36,11 @@ impl WasmModuleSource {

pub fn from_module_bytes(
data: Arc<Vec<u8>>,
module_name: &str,
cache_config_path: &Path,
) -> anyhow::Result<WasmModuleSource> {
let engine = Self::new_engine(cache_config_path)?;
let module = wasmtime::Module::new(&engine, &**data)?;
let module = wasmtime::Module::new_with_name(&engine, &**data, module_name)?;
Ok(WasmModuleSource::Compiled(module, engine))
}