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

🚩PR: Fixed bug of runtime error when connecting/reconnecting many modules #714

Merged
merged 1 commit into from
May 7, 2024
Merged
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
Initial solution
  • Loading branch information
elsoazemelet committed May 3, 2024
commit d619f3bc0973fe437ab33f0ad341d88f38d139a0
30 changes: 19 additions & 11 deletions src/renderer/runtime/runtime.store.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,18 +480,26 @@ function create_runtime() {
});
}

let lastDate = get(heartbeat).find(
const lastDate = get(heartbeat).find(
(device) => device.id == controller.id
).alive;
let newDate = Date.now();
get(heartbeat).find((device) => device.id == controller.id).alive =
newDate;
)?.alive;
if (lastDate) {
let newDate = Date.now();

heartbeat.update((store) => {
const device = store.find((device) => device.id == controller.id);
if (device) {
device.alive = newDate;
}
return store;
});

//console.log(newDate - lastDate)
if (get(appSettings).persistent.heartbeatDebugEnabled) {
const key1 = `Hearbeat (${controller.dx}, ${controller.dy})`;
//console.log(newDate - lastDate)
if (get(appSettings).persistent.heartbeatDebugEnabled) {
const key1 = `Hearbeat (${controller.dx}, ${controller.dy})`;

add_datapoint(key1, newDate - lastDate);
add_datapoint(key1, newDate - lastDate);
}
}
}
// device not found, add it to runtime and get page count from grid
Expand Down Expand Up @@ -1212,7 +1220,7 @@ const grid_heartbeat_interval_handler = async function () {
return;
}

const alive = get(heartbeat).find((e) => e.id == device.id).alive;
const alive = get(heartbeat).find((e) => e.id == device.id)?.alive;

// Allow less strict elapsedTimeLimit while writeBuffer is busy!
const elapsedTimeLimit =
Expand All @@ -1221,7 +1229,7 @@ const grid_heartbeat_interval_handler = async function () {
: heartbeat_grid_ms * 3;
const elapsedTime = Date.now() - alive;

if (elapsedTime > elapsedTimeLimit) {
if (!alive || elapsedTime > elapsedTimeLimit) {
// TIMEOUT! let's remove the device
runtime.destroy_module(device.dx, device.dy);
heartbeat.update((heartbeat) => {
Expand Down
Loading