Skip to content

Commit 6d9bcfe

Browse files
authored
Don't crash wk when ad-hoc meshing fails (#8716)
Previously, wk crashed completely when the ad-hoc meshing fails (e.g., because the backend timed out). There are also other sagas which could be made more resilient, but that's something bigger in my opinion (see #8715). Therefore, this PR simply adds a simple try-catch and an error toast. ### URL of deployed dev instance (used for testing): - https://___.webknossos.xyz ### Steps to test: - I added a `throw new Error("...")` to the meshing saga and got a simple error toast asking me to retry - no need to test further in my opinion ### Issues: - contributes to #8715 ------ (Please delete unneeded items, merge only when none are left open) - [x] Added changelog entry (create a `$PR_NUMBER.md` file in `unreleased_changes` or use `./tools/create-changelog-entry.py`)
1 parent 41a0989 commit 6d9bcfe

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

frontend/javascripts/viewer/model/sagas/meshes/ad_hoc_mesh_saga.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
import ThreeDMap from "libs/ThreeDMap";
77
import ErrorHandling from "libs/error_handling";
88
import { V3 } from "libs/mjs";
9+
import Toast from "libs/toast";
910
import { sleep } from "libs/utils";
1011
import _ from "lodash";
1112
import type { ActionPattern } from "redux-saga/effects";
@@ -177,15 +178,20 @@ function* loadAdHocMeshFromAction(action: LoadAdHocMeshAction): Saga<void> {
177178
// Remove older mesh instance if it exists already.
178179
yield* put(removeMeshAction(layer.name, action.segmentId));
179180

180-
yield* call(
181-
loadAdHocMesh,
182-
action.seedPosition,
183-
action.seedAdditionalCoordinates,
184-
action.segmentId,
185-
false,
186-
layer.name,
187-
action.extraInfo,
188-
);
181+
try {
182+
yield* call(
183+
loadAdHocMesh,
184+
action.seedPosition,
185+
action.seedAdditionalCoordinates,
186+
action.segmentId,
187+
false,
188+
layer.name,
189+
action.extraInfo,
190+
);
191+
} catch (exc) {
192+
Toast.error(`The mesh for segment ${action.segmentId} could not be loaded. Please try again.`);
193+
ErrorHandling.notify(exc as any);
194+
}
189195
}
190196

191197
export function* getMeshExtraInfo(

unreleased_changes/8716.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### Fixed
2+
- Fixed a crash when an ad-hoc mesh could not be loaded for some reason.

0 commit comments

Comments
 (0)