-
Notifications
You must be signed in to change notification settings - Fork 348
Application restart breaks WebAssembly Components #1179
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
Comments
Update. This may or may not be related but after configuring a |
Yes, sounds like something funky going on, looking at it... |
The processes weren't exit(2)ing.. Try this diff --git a/src/wasm-wasi-component/src/lib.rs b/src/wasm-wasi-component/src/lib.rs
index 3ee40c4f..47c94bdc 100644
--- a/src/wasm-wasi-component/src/lib.rs
+++ b/src/wasm-wasi-component/src/lib.rs
@@ -4,6 +4,7 @@ use http_body_util::combinators::BoxBody;
use http_body_util::{BodyExt, Full};
use std::ffi::{CStr, CString};
use std::mem::MaybeUninit;
+use std::process;
use std::ptr;
use std::sync::OnceLock;
use tokio::sync::mpsc;
@@ -126,7 +127,7 @@ unsafe extern "C" fn start(
bindings::nxt_unit_run(unit_ctx);
bindings::nxt_unit_done(unit_ctx);
- Ok(())
+ process::exit(0x0);
})
} |
Thanks for looking! I've done a cursory test with this patch and at first glance it works as expected. I can Side note: it would be more convenient if libwasm_wasi_component.so was compiled with a _unit.so suffix so that it can be disovered without first renaming (or requiring |
I also replicated that the fix works. 👍
I believe I ran into this too. Make doesn't appear pick up on changes to lib.rs. |
Thanks!, I'll add both your
You have to really fight against cargo to get it named differently, we do that for macOS... I suppose we could do it for the others, but I'm not sure if there is any other practical differences between NXT_OS=$(uname -s)
if [ $NXT_OS = "Darwin" ]; then
NXT_CARGO_CMD="cargo rustc --release --manifest-path src/wasm-wasi-component/Cargo.toml -- --emit link=target/release/libwasm_wasi_component.so -C link-args='-undefined dynamic_lookup'"
else
NXT_CARGO_CMD="cargo build --release --manifest-path src/wasm-wasi-component/Cargo.toml"
fi
Heh, yes, a slightly different issue, but I also have that fixed. PR coming shortly... |
Liam reported a problem when trying to restart wasm-wasi-component based applications using the /control/applications/APPLICATION_NAME/restart endpoint. The application would become unresponsive. What was happening was the old application process(es) weren't exit(2)ing and so while we were starting new application processes, the old ones were still hanging around in a non-functioning state. When we are terminating an application it must call exit(2). So that's what we do. We want to use the standard EXIT_SUCCESS mnemonic, which in rust is available in external crates such as libc, however rather than bringing in a whole nother crate just for this, we just define it locally ourselves. Reported-by: Liam Crilly <[email protected]> Fixes: 20ada4b ("Wasm-wc: Core of initial Wasm component model language module support") Closes: nginx#1179 Tested-by: Liam Crilly <[email protected]> Tested-by: Danielle De Leo <[email protected]> Signed-off-by: Andrew Clayton <[email protected]>
Liam reported a problem when trying to restart wasm-wasi-component based applications using the /control/applications/APPLICATION_NAME/restart endpoint. The application would become unresponsive. What was happening was the old application process(es) weren't exit(2)ing and so while we were starting new application processes, the old ones were still hanging around in a non-functioning state. When we are terminating an application it must call exit(2). So that's what we do. We want to use the standard EXIT_SUCCESS mnemonic, which in rust is available in external crates such as libc, however rather than bringing in a whole nother crate just for this, we just define it locally ourselves. Reported-by: Liam Crilly <[email protected]> Fixes: 20ada4b ("Wasm-wc: Core of initial Wasm component model language module support") Closes: nginx#1179 Tested-by: Liam Crilly <[email protected]> Tested-by: Danielle De Leo <[email protected]> Signed-off-by: Andrew Clayton <[email protected]>
Liam reported a problem when trying to restart wasm-wasi-component based applications using the /control/applications/APPLICATION_NAME/restart endpoint. The application would become unresponsive. What was happening was the old application process(es) weren't exit(2)ing and so while we were starting new application processes, the old ones were still hanging around in a non-functioning state. When we are terminating an application it must call exit(2). So that's what we do. We want to use the standard EXIT_SUCCESS mnemonic, which in rust is available in external crates such as libc, however rather than bringing in a whole nother crate just for this, we just define it locally ourselves. Reported-by: Liam Crilly <[email protected]> Fixes: 20ada4b ("Wasm-wc: Core of initial Wasm component model language module support") Closes: nginx#1179 Tested-by: Liam Crilly <[email protected]> Tested-by: Danielle De Leo <[email protected]> Signed-off-by: Andrew Clayton <[email protected]>
Liam reported a problem when trying to restart wasm-wasi-component based applications using the /control/applications/APPLICATION_NAME/restart endpoint. The application would become unresponsive. What was happening was the old application process(es) weren't exit(3)ing and so while we were starting new application processes, the old ones were still hanging around in a non-functioning state. When we are terminating an application it must call exit(3). So that's what we do. We use the return value of nxt_unit_run() as the exit status. Reported-by: Liam Crilly <[email protected]> Fixes: 20ada4b ("Wasm-wc: Core of initial Wasm component model language module support") Closes: nginx#1179 Tested-by: Liam Crilly <[email protected]> Tested-by: Danielle De Leo <[email protected]> Signed-off-by: Andrew Clayton <[email protected]>
If either of you want to test the latest version of the patch, particularly if you have arm64 hardware... I'm really interested in if the language module builds without error. |
OK, I found an arm64 machine to test on and I suspected, it fails to build there... |
Liam reported a problem when trying to restart wasm-wasi-component based applications using the /control/applications/APPLICATION_NAME/restart endpoint. The application would become unresponsive. What was happening was the old application process(es) weren't exit(3)ing and so while we were starting new application processes, the old ones were still hanging around in a non-functioning state. When we are terminating an application it must call exit(3). So that's what we do. We use the return value of nxt_unit_run() as the exit status. Reported-by: Liam Crilly <[email protected]> Fixes: 20ada4b ("Wasm-wc: Core of initial Wasm component model language module support") Closes: nginx#1179 Tested-by: Liam Crilly <[email protected]> Tested-by: Danielle De Leo <[email protected]> Signed-off-by: Andrew Clayton <[email protected]>
Liam reported a problem when trying to restart wasm-wasi-component based applications using the /control/applications/APPLICATION_NAME/restart endpoint. The application would become unresponsive. What was happening was the old application process(es) weren't exit(3)ing and so while we were starting new application processes, the old ones were still hanging around in a non-functioning state. When we are terminating an application it must call exit(3). So that's what we do. We use the return value of nxt_unit_run() as the exit status. Due to exit(3)ing we also need to now explicitly handle the return on error case. Reported-by: Liam Crilly <[email protected]> Fixes: 20ada4b ("Wasm-wc: Core of initial Wasm component model language module support") Closes: nginx#1179 Tested-by: Liam Crilly <[email protected]> Tested-by: Danielle De Leo <[email protected]> Signed-off-by: Andrew Clayton <[email protected]>
Liam reported a problem when trying to restart wasm-wasi-component based applications using the /control/applications/APPLICATION_NAME/restart endpoint. The application would become unresponsive. What was happening was the old application process(es) weren't exit(3)ing and so while we were starting new application processes, the old ones were still hanging around in a non-functioning state. When we are terminating an application it must call exit(3). So that's what we do. We use the return value of nxt_unit_run() as the exit status. Due to exit(3)ing we also need to now explicitly handle the return on error case. Reported-by: Liam Crilly <[email protected]> Fixes: 20ada4b ("Wasm-wc: Core of initial Wasm component model language module support") Closes: nginx#1179 Tested-by: Liam Crilly <[email protected]> Tested-by: Danielle De Leo <[email protected]> Co-developed-by: Dan Callahan <[email protected]> Signed-off-by: Dan Callahan <[email protected]> Signed-off-by: Andrew Clayton <[email protected]>
Liam reported a problem when trying to restart wasm-wasi-component based applications using the /control/applications/APPLICATION_NAME/restart endpoint. The application would become unresponsive. What was happening was the old application process(es) weren't exit(3)ing and so while we were starting new application processes, the old ones were still hanging around in a non-functioning state. When we are terminating an application it must call exit(3). So that's what we do. We use the return value of nxt_unit_run() as the exit status. Due to exit(3)ing we also need to now explicitly handle the return on error case. Reported-by: Liam Crilly <[email protected]> Fixes: 20ada4b ("Wasm-wc: Core of initial Wasm component model language module support") Closes: #1179 Tested-by: Liam Crilly <[email protected]> Tested-by: Danielle De Leo <[email protected]> Co-developed-by: Dan Callahan <[email protected]> Signed-off-by: Dan Callahan <[email protected]> Signed-off-by: Andrew Clayton <[email protected]>
Liam reported a problem when trying to restart wasm-wasi-component based applications using the /control/applications/APPLICATION_NAME/restart endpoint. The application would become unresponsive. What was happening was the old application process(es) weren't exit(3)ing and so while we were starting new application processes, the old ones were still hanging around in a non-functioning state. When we are terminating an application it must call exit(3). So that's what we do. We use the return value of nxt_unit_run() as the exit status. Due to exit(3)ing we also need to now explicitly handle the return on error case. Reported-by: Liam Crilly <[email protected]> Fixes: 20ada4b ("Wasm-wc: Core of initial Wasm component model language module support") Closes: nginx#1179 Tested-by: Liam Crilly <[email protected]> Tested-by: Danielle De Leo <[email protected]> Co-developed-by: Dan Callahan <[email protected]> Signed-off-by: Dan Callahan <[email protected]> Signed-off-by: Andrew Clayton <[email protected]>
According to the documentation I should be able to restart any application by making a
GET
request to the appropriate /control/applications/… API endpoint.This is not working for WebAssembly Components. The restart request is accepted but subsequent calls to the application timeout.
Here is my reproducer based on this simple hello world component.
The text was updated successfully, but these errors were encountered: