mirror of
https://github.com/tauri-apps/tauri.git
synced 2024-09-19 20:28:54 +03:00
fix(cli): properly exit with code 0 on panic when running with bun (#10572)
This commit is contained in:
parent
f8d658ea1b
commit
41c7a6646b
5
.changes/fix-cli-panic-bun.md
Normal file
5
.changes/fix-cli-panic-bun.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"@tauri-apps/cli": patch:bug
|
||||
---
|
||||
|
||||
Exit with code 1 if a panic occurs when running the CLI with `bun`.
|
@ -14,12 +14,29 @@ pub fn run(args: Vec<String>, bin_name: Option<String>, callback: JsFunction) ->
|
||||
|
||||
// we need to run in a separate thread so Node.js consumers
|
||||
// can do work while `tauri dev` is running.
|
||||
std::thread::spawn(move || match tauri_cli::try_run(args, bin_name) {
|
||||
Ok(_) => function.call(Ok(true), ThreadsafeFunctionCallMode::Blocking),
|
||||
Err(e) => function.call(
|
||||
Err(Error::new(Status::GenericFailure, format!("{:#}", e))),
|
||||
ThreadsafeFunctionCallMode::Blocking,
|
||||
),
|
||||
std::thread::spawn(move || {
|
||||
let res = match std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
|
||||
tauri_cli::try_run(args, bin_name)
|
||||
})) {
|
||||
Ok(t) => t,
|
||||
Err(e) => {
|
||||
return function.call(
|
||||
Err(Error::new(
|
||||
Status::GenericFailure,
|
||||
"Tauri CLI unexpected panic",
|
||||
)),
|
||||
ThreadsafeFunctionCallMode::Blocking,
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
match res {
|
||||
Ok(_) => function.call(Ok(true), ThreadsafeFunctionCallMode::Blocking),
|
||||
Err(e) => function.call(
|
||||
Err(Error::new(Status::GenericFailure, format!("{:#}", e))),
|
||||
ThreadsafeFunctionCallMode::Blocking,
|
||||
),
|
||||
}
|
||||
});
|
||||
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user