Skip to content
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

Retry IDE controller initialization. #5802

Merged
merged 6 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@
- [The Component Browser icons are cached on texture][5779] improving its
performance on slower machines.
- [Fixed missing result preview when editing nodes.][5757]
- [Application retries its initialization after failures][5802], allowing a
reconnecting after connectivity problems.

#### EnsoGL (rendering engine)

Expand Down Expand Up @@ -505,6 +507,7 @@
[5721]: https://github.com/enso-org/enso/pull/5721
[5779]: https://github.com/enso-org/enso/pull/5779
[5757]: https://github.com/enso-org/enso/pull/5757
[5802]: https://github.com/enso-org/enso/pull/5802

#### Enso Compiler

Expand Down
43 changes: 32 additions & 11 deletions app/gui/src/ide/initializer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ use crate::FailedIde;

use engine_protocol::project_manager;
use engine_protocol::project_manager::ProjectName;
use enso_web::sleep;
use ensogl::application::Application;
use std::time::Duration;
use uuid::Uuid;


Expand All @@ -23,6 +25,13 @@ use uuid::Uuid;
// https://github.com/enso-org/ide/issues/1034
const PROJECT_MANAGER_TIMEOUT_SEC: u64 = 2 * 60 * 60;

/// Times to wait for the subsequent IDE initialization retry.
///
/// The IDE initialization is prone to connectivity problems, therefore we retry it several times.
/// The number of retries is equal to this slice length.
const INITIALIZATION_RETRY_TIMES: &[Duration] =
&[Duration::from_secs(1), Duration::from_secs(2), Duration::from_secs(4)];



// ==============
Expand Down Expand Up @@ -81,17 +90,29 @@ impl Initializer {
// TODO [mwu] Once IDE gets some well-defined mechanism of reporting
// issues to user, such information should be properly passed
// in case of setup failure.
match self.initialize_ide_controller().await {
Ok(controller) => {
let ide = Ide::new(ensogl_app, view.clone_ref(), controller);
info!("Setup done.");
Ok(ide)
}
Err(error) => {
let message = format!("Failed to initialize application: {error}");
error!("{message}");
status_bar.add_event(ide_view::status_bar::event::Label::new(message));
Err(FailedIde { view })

let mut retry_after = INITIALIZATION_RETRY_TIMES.iter();
loop {
match self.initialize_ide_controller().await {
Ok(controller) => {
let ide = Ide::new(ensogl_app, view.clone_ref(), controller);
info!("Setup done.");
break Ok(ide);
}
Err(error) => {
let message = format!("Failed to initialize application: {error}");
error!("{message}");
match retry_after.next() {
Some(time) => {
error!("Retrying after {} seconds", time.as_secs_f32());
sleep(*time).await;
}
None => {
status_bar.add_event(ide_view::status_bar::event::Label::new(message));
break Err(FailedIde { view });
}
}
}
}
}
}
Expand Down