Unfortunately requires forcing the LLVM codegen backend for now as Cranelift support for unwinding is still experimental. Also delays getting the extension state in on_did functions to prevent looping after a panic.
6AUGQLIKK6WY3ZB3ZQ4PCN6NXRLP65CLF2YMOTDDAP6QQAIGGELQC $function_create_owned_return_type(returned_result)
let function_return_value = match std::panic::catch_unwind(|| function_callback(function_context.env, $($function_argument_name),*)) {Ok(function_result) => function_result?,Err(panic_payload) => {tracing::error!(message = "Function panic",event_handler = $function_js_name,?panic_payload);return Err(napi::Error::from_reason("Function panic"));}};$function_create_owned_return_type(function_return_value)
if let Err(error) = handler(function_context.env, event) {tracing::error!(message = "Handler exited unsuccessfully",event_handler = $function_js_name,?error);}
match std::panic::catch_unwind(|| handler(function_context.env, event)) {Ok(handler_result) => match handler_result {Ok(result) => Ok(result),Err(error) => {tracing::error!(message = "Event handler returned an error",event_handler = $function_js_name,?error);
Ok(())
Err(napi::Error::from_reason("Event handler returned an error"))}},Err(panic_payload) => {tracing::error!(message = "Event handler panicked",event_handler = $function_js_name,?panic_payload);Err(napi::Error::from_reason("Event handler panicked"))}}
# Cranelift doesn't support unwinding, so make sure to use LLVM as the codegen backend# TODO: remove this workaround once unwinding is stable on Linux:# https://github.com/rust-lang/rustc_codegen_cranelift/issues/1567[unstable]codegen-backend = true[profile.dev]codegen-backend = "llvm"