I believe there is a bug in the code where when you send a local response which overrides the action, and trap after it nginx will then segfault when trying to cleanup the request and the 503 response is not sent.
Probably issue here, I believe trapping should have higher priority then action
https://github.com/Kong/ngx_wasm_module/blob/main/src/common/proxy_wasm/ngx_proxy_wasm.c#L864-L890