Skip to content

Feat: Add "Plugin Crash" to messages logged when plugins crash within v8 to improve error observability #450

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
12 changes: 7 additions & 5 deletions src/v8/v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class V8 : public WasmVm {
private:
wasm::own<wasm::Trap> trap(std::string message);

std::string getFailMessage(std::string_view function_name, wasm::own<wasm::Trap> trap);
std::string getPluginFailMessage(std::string_view function_name, wasm::own<wasm::Trap> trap);

template <typename... Args>
void registerHostFunctionImpl(std::string_view module_name, std::string_view function_name,
Expand Down Expand Up @@ -638,7 +638,8 @@ void V8::getModuleFunctionImpl(std::string_view function_name,
}

if (trap) {
fail(FailState::RuntimeError, getFailMessage(std::string(function_name), std::move(trap)));
fail(FailState::RuntimeError,
getPluginFailMessage(std::string(function_name), std::move(trap)));
return;
}
if (log) {
Expand Down Expand Up @@ -690,7 +691,8 @@ void V8::getModuleFunctionImpl(std::string_view function_name,
}

if (trap) {
fail(FailState::RuntimeError, getFailMessage(std::string(function_name), std::move(trap)));
fail(FailState::RuntimeError,
getPluginFailMessage(std::string(function_name), std::move(trap)));
return R{};
}
R rvalue = results[0].get<typename ConvertWordTypeToUint32<R>::type>();
Expand All @@ -708,8 +710,8 @@ void V8::terminate() {
isolate->TerminateExecution();
}

std::string V8::getFailMessage(std::string_view function_name, wasm::own<wasm::Trap> trap) {
auto message = "Function: " + std::string(function_name) + " failed: ";
std::string V8::getPluginFailMessage(std::string_view function_name, wasm::own<wasm::Trap> trap) {
auto message = "Plugin Crash: Function: " + std::string(function_name) + " failed: ";
message += std::string(trap->message().get(), trap->message().size());

if (function_names_index_.empty()) {
Expand Down
Loading