Skip to content

Commit dac9547

Browse files
committed
Handle DGGS WASM load failures and fix stale panel comments.
CodeRabbit still requested try/catch around activate loads and comments that matched updatePanelStatus instead of a full rebuild.
1 parent 47e17c3 commit dac9547

2 files changed

Lines changed: 22 additions & 6 deletions

File tree

packages/plugins/src/plugins/maplibre-dggal.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,8 @@ function refresh(): void {
636636
applyStyle();
637637
(map.getSource(SOURCE_ID) as GeoJSONSource | undefined)?.setData(currentGrid);
638638
updateSelectedSource();
639-
// Pan/zoom only changes the cell count status — rebuild the whole panel and
640-
// the open color picker / focused inputs are destroyed mid-gesture.
639+
// Pan/zoom only updates the status line (and auto-resolution readout) —
640+
// rebuilding the whole panel would destroy open color pickers / focused inputs.
641641
updatePanelStatus();
642642
}
643643

@@ -1042,7 +1042,15 @@ export const maplibreDggalPlugin: GeoLibrePlugin = {
10421042
const generation = (activationGeneration += 1);
10431043
// Await WASM before mutating map/panel state so a deactivate during the
10441044
// load cannot race a late attach (leaked listeners / panels / layers).
1045-
const engine = await loadDggal();
1045+
let engine: DggalEngine;
1046+
try {
1047+
engine = await loadDggal();
1048+
} catch (error) {
1049+
if (generation === activationGeneration) {
1050+
currentError = error instanceof Error ? error.message : String(error);
1051+
}
1052+
return false;
1053+
}
10461054
if (generation !== activationGeneration) return false;
10471055
dggal = engine;
10481056
map = activeMap;

packages/plugins/src/plugins/maplibre-dggrid.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,8 @@ function refresh(): void {
860860
applyStyle();
861861
(map.getSource(SOURCE_ID) as GeoJSONSource | undefined)?.setData(currentGrid);
862862
updateSelectedSource();
863-
// Pan/zoom only changes the cell count status — rebuild the whole panel and
864-
// the open color picker / focused inputs are destroyed mid-gesture.
863+
// Pan/zoom only updates the status line (and auto-resolution readout) —
864+
// rebuilding the whole panel would destroy open color pickers / focused inputs.
865865
updatePanelStatus();
866866
}
867867

@@ -1267,7 +1267,15 @@ export const maplibreDggridPlugin: GeoLibrePlugin = {
12671267
const generation = (activationGeneration += 1);
12681268
// Await WASM before mutating map/panel state so a deactivate during the
12691269
// load cannot race a late attach (leaked listeners / panels / layers).
1270-
const engine = await loadDggrid();
1270+
let engine: DggridEngine;
1271+
try {
1272+
engine = await loadDggrid();
1273+
} catch (error) {
1274+
if (generation === activationGeneration) {
1275+
currentError = error instanceof Error ? error.message : String(error);
1276+
}
1277+
return false;
1278+
}
12711279
if (generation !== activationGeneration) return false;
12721280
dggs = engine;
12731281
map = activeMap;

0 commit comments

Comments
 (0)