louis-e/arnis · error · Error
No preview data available
Error message
No preview data available
What it means
ensureProtocol registers a custom maplibregl protocol handler for arnisdem:// URLs; when maplibre requests a tile, the handler parses the dataset id from the URL and looks it up in the module-local datasets Map. If no dataset with that id is registered (or the regex doesn't match), the handler rejects with this Error, surfacing as a failed tile request in the map.
Source
Thrown at src/gui/js/preview3d.js:199
px[i++] = whole % 256;
px[i++] = Math.floor((e - whole) * 256);
px[i++] = 255;
}
}
return img;
}
// The terrain and hillshade sources request every tile with the same URL;
// caching the synthesized ImageData halves the per-tile sampling work.
const tileCache = new Map();
const TILE_CACHE_MAX = 48;
function ensureProtocol() {
if (protocolRegistered) return;
maplibregl.addProtocol(PROTOCOL, async (params) => {
const m = params.url.match(/^arnisdem:\/\/(\d+)\/(\d+)\/(\d+)\/(\d+)/);
const d = m && datasets.get(+m[1]);
if (!d) throw new Error("No preview data available");
let img = tileCache.get(params.url);
if (!img) {
img = renderDemTile(d, +m[2], +m[3], +m[4]);
tileCache.set(params.url, img);
if (tileCache.size > TILE_CACHE_MAX) {
tileCache.delete(tileCache.keys().next().value);
}
}
return { data: await createImageBitmap(img) };
});
protocolRegistered = true;
}
function landCoverUrl(grid, gw, gh) {
const canvas = document.createElement("canvas");
canvas.width = gw;
canvas.height = gh;
const ctx = canvas.getContext("2d");View on GitHub (pinned to 34048924d9)
Solutions
- Ensure the dataset is registered via datasets.set(id, d) before adding/using any arnisdem:// source, and keep the id consistent with the tile URLs in the source.
- Remove the map source and detach the map when the dataset is deleted/regenerated instead of leaving stale arnisdem:// URLs live.
- Catch the rejection in the protocol handler flow (maplibre surfaces it as a source error event); listen to map.on('error') and ignore/suppress errors for known-stale dataset ids.
- If ids are derived from user input, validate they are numeric before building arnisdem:// URLs.
- Clear tileCache and rebuild the source with the new dataset id whenever the preview is regenerated.
Example fix
// before
map.setTerrain({ source: "dem", ... }); // dem source still uses old arnisdem://7/... id after regen
// after
map.on("error", (e) => {
if (String(e.error && e.error.message).includes("No preview data available")) return; // stale tile
console.error(e);
});
// and on regeneration:
if (map.getSource("dem")) map.removeSource("dem");
addDemSource(map, newDatasetId); Defensive patterns
Strategy: try-catch
Validate before calling
const ds = typeof datasetId === "number" && Number.isInteger(datasetId) ? datasetId : null;
if (ds == null || !datasetRegistryHas(ds)) { skipMapSetup(); return; } Type guard
function hasDataset(id) { return Number.isInteger(id) && datasets.has(id); } Try / catch
map.on("error", (e) => {
if (e && e.error && e.error.message === "No preview data available") return; // stale tile for old dataset
console.error("map error:", e);
}); Prevention
- Register the dataset before adding any arnisdem:// source to the map.
- Remove map sources/terrain when a dataset is deleted or regenerated.
- Validate dataset ids are numeric before embedding them in tile URLs.
- Add a map 'error' listener that tolerates stale-tile failures.
When it happens
Trigger: A maplibre source with tiles under arnisdem://<datasetId>/... is still attached to a live map after the dataset was removed from the datasets Map (e.g. preview regenerated, selection cleared, or module state reset), or the URL does not match the /^arnisdem:\/\/(\d+)\/(\d+)\/(\d+)\/(\d+)/ pattern (e.g. non-numeric id), so `d` is undefined.
Common situations: Stale DEM tile requests from a previous map instance racing with a regenerated preview; a cached map style JSON referencing an old dataset id; calling createTerrainMap before the dataset was added to the registry; hot module reload clearing the module-level Map while the map keeps requesting tiles.
Related errors
- Unexpected preview payload format
- land cover grid mismatch
- Failed to get main window
- Error while starting the application UI (Tauri)
AI-assisted analysis of louis-e/arnis@34048924d9 (2026-09-03).
Data as JSON: /api/errors/55096fc25cfbe1c2.
Report an issue: GitHub.