BabylonJS/Babylon.js · error
Unable to save your ${entityName ?? "content"}: ${e}
Error message
Unable to save your ${entityName ?? "content"}: ${e} What it means
SaveToSnippetServer wraps the fetch() POST to the snippet server in a try/catch; if the network request itself throws (never reaches an HTTP response), it builds this message including the underlying error text, calls alert(), and rethrows with the original error as `cause`. It exists to tell the user which entity type (e.g. 'particle system') failed to save while preserving the root cause (network failure, CORS, invalid URL, server unreachable).
Source
Thrown at packages/dev/inspector-v2/src/misc/snippetUtils.ts:82
name: "",
description: "",
tags: "",
};
const headers = new Headers();
headers.append("Content-Type", "application/json");
let response: Response;
try {
response = await fetch(snippetUrl + (currentSnippetId ? "/" + currentSnippetId : ""), {
method: "POST",
headers,
body: JSON.stringify(dataToSend),
});
} catch (e) {
const errorMsg = `Unable to save your ${entityName ?? "content"}: ${e}`;
alert(errorMsg);
throw new Error(errorMsg, { cause: e });
}
if (!response.ok) {
const errorMsg = `Unable to save your ${entityName ?? "content"}`;
alert(errorMsg);
throw new Error(errorMsg);
}
const snippet = await response.json();
const oldSnippetId = currentSnippetId || "_BLANK";
let newSnippetId = snippet.id;
if (snippet.version && snippet.version !== "0") {
newSnippetId += "#" + snippet.version;
}
// Copy to clipboard when available.
if (navigator.clipboard) {
await navigator.clipboard.writeText(newSnippetId);
View on GitHub (pinned to 0592b347b8)
Solutions
- Verify the snippet server is running and that config.snippetUrl points at the correct host/port/protocol (https on https pages).
- Open the browser console/network tab and inspect `e` (the Error.cause) to see if it is CORS, DNS, or a connection refusal, and fix that root cause.
- If self-hosting the snippet server, enable CORS headers for the page origin.
- Add retry logic or a health check against snippetUrl before invoking save.
- If you only need local persistence, bypass the server and store the content via localStorage instead.
Example fix
// before: fails silently into alert when server is down
await SaveToSnippetServer({ snippetUrl: "http://localhost:1338", content, payloadKey: "particleSystem" });
// after: probe server first and fall back
async function saveSnippet(config) {
try {
await fetch(config.snippetUrl, { method: "HEAD" });
} catch {
localStorage.setItem("snippet-backup", config.content);
throw new Error("Snippet server unreachable; content backed up locally");
}
return SaveToSnippetServer(config);
} Defensive patterns
Strategy: try-catch
Validate before calling
async function assertSnippetServerReady(snippetUrl) {
const u = new URL(snippetUrl);
if (window.location.protocol === "https:" && u.protocol !== "https:") {
throw new Error("Mixed content: snippet server must use https");
}
await fetch(snippetUrl, { method: "HEAD" });
} Try / catch
try {
const result = await SaveToSnippetServer(config);
} catch (e) {
console.error("Snippet save failed:", e.cause ?? e);
// e.cause holds the original fetch error (CORS, DNS, offline)
localStorage.setItem("snippet-backup:" + config.payloadKey, config.content);
} Prevention
- HEAD-check the snippet server on inspector startup and show a status indicator.
- Keep snippetUrl in one config source and validate protocol against the page origin.
- Enable CORS on any self-hosted snippet server.
- Back up content to localStorage on save failure so work is never lost.
When it happens
Trigger: Calling SaveToSnippetServer when fetch() rejects: snippet server host unreachable or offline, invalid/incorrect snippetUrl (bad protocol, typo, mixed HTTP/HTTPS content blocking), CORS rejection, browser offline, DNS failure, or the request aborted before a Response is produced.
Common situations: Running the inspector against a locally started snippet server that is not running yet; a snippetUrl with a trailing typo or wrong port; CORS not enabled on a self-hosted snippet server; corporate proxy/firewall blocking the request; testing in an environment without network access.
Related errors
- Unable to load your ${entityName ?? "content"}: ${e}
- Failed to fetch image "${url}": ${response.status} ${respons
- Failed to fetch KTX2 file "${data}": ${response.status} ${re
- SmartAssetSerializer: Failed to fetch "${source}" — HTTP ${r
- Unable to save your ${entityName ?? "content"}
AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30).
Data as JSON: /api/errors/70398bcb6206c14c.
Report an issue: GitHub.