Skip to content

Commit

Permalink
errors that cause the component to become unusable should crash the p…
Browse files Browse the repository at this point in the history
…rocess
  • Loading branch information
Chris Nelson committed Dec 21, 2024
1 parent bdbd1fe commit 72e5fb1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion native/wasmex/src/component_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pub fn component_call_function<'a>(
let _ = function.post_return(&mut *component_store);
Ok(encode_result(env, result))
}
Err(err) => Err(rustler::Error::Term(Box::new(format!(
Err(err) => Err(rustler::Error::RaiseTerm(Box::new(format!(
"Error executing function: {err}"
)))),
}
Expand Down
9 changes: 9 additions & 0 deletions test/components/components_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ defmodule Wasmex.ComponentsTest do
assert {:error, _error} = Wasmex.Components.call_function(component_pid, "garbage", ["wut"])
end

test "unrecoverable errors crash the process" do
component_bytes = File.read!("test/component_fixtures/component_types/component_types.wasm")
component_pid = start_supervised!({Wasmex.Components, %{bytes: component_bytes}})

assert catch_exit(
Wasmex.Components.call_function(component_pid, "id-record", [%{not: "expected"}])
)
end

test "using the component macro" do
component_bytes = File.read!("test/component_fixtures/hello_world/hello_world.wasm")

Expand Down

0 comments on commit 72e5fb1

Please sign in to comment.