parallax/jsPDF · error · Error
Unable to load file ${url}
Error message
Unable to load file ${url} What it means
This lives in builder.html, the jsPDF web-based module builder. loadBinaryResource performs a synchronous XMLHttpRequest (req.open('GET', url, false)) with the MIME overridden to 'text/plain; charset=x-user-defined' so binary bytes survive as a string. After req.send, if req.status !== 200 it throws 'Unable to load file <url>'. Because the throw is caught locally and only alert(e)'d, execution then falls through to req.responseText (empty/garbage), so a failed load both alerts and silently corrupts the build. Note that file:// and CORS failures yield status 0, which is also !== 200 and triggers the throw.
Source
Thrown at builder.html:150
form.submit(function( event ) {
var formValues = form.serializeArray();
formValues = formValues.filter(function(item) {
return (item.name !== 'all');
});
build ( formValues );
event.preventDefault();
});
});
function loadBinaryResource (url, unicodeCleanUp) {
var req = new XMLHttpRequest()
req.open('GET', url, false)
// XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com]
req.overrideMimeType('text\/plain; charset=x-user-defined');
try {
req.send(null)
if (req.status !== 200) {
throw new Error('Unable to load file ' + url);
}
} catch (e) {
alert(e);
}
var responseText = req.responseText;
var StringFromCharCode = String.fromCharCode;
if (unicodeCleanUp === true) {
var i = 0;
for (i = 0; i < responseText.length; i += 1) {
byteArray.push(StringFromCharCode(responseText.charCodeAt(i) & 0xff))
}
return byteArray.join("");
}
return req.responseText;
}
function uniq(a) {View on GitHub (pinned to a3930ce03a)
Solutions
- Serve the project over HTTP instead of opening the file directly: e.g. `python3 -m http.server` or `npx serve`, then open http://localhost:PORT/builder.html.
- Open the browser Network tab and confirm the failing URL; fix the path or restore the missing file.
- Deselect (uncheck) the module whose file cannot be found, or update configuration to the correct folder.
- If a custom dev server returns non-200 for valid files, fix its routing/static mapping before rebuilding.
Example fix
# before # open builder.html via file:///home/me/repo/builder.html -> XHR status 0 -> throws # after python3 -m http.server 8000 # then visit http://localhost:8000/builder.html
Defensive patterns
Strategy: validation
Validate before calling
function ensureServable() {
if (/^file:/i.test(globalThis.location.protocol)) {
throw new Error('builder.html must be served over http(s), not opened via file://. Run: python3 -m http.server');
}
}
function probeUrl(url) {
var x = new XMLHttpRequest(); x.open('HEAD', url, false); x.send(null);
return x.status === 200;
}
// before building: ensureServable(); if (!probeUrl(fileUrl)) { /* skip/fix this module */ } Try / catch
try {
var data = loadBinaryResource(url, true);
if (!data) throw new Error('Empty response for ' + url);
} catch (e) {
console.error('Build stopped: could not load', url, '-', e.message);
// do NOT fall through to use req.responseText; surface the failure to the user and abort the build.
throw e;
} Prevention
- Always serve the repo over HTTP (python3 -m http.server / npx serve) — never open builder.html via file://.
- Keep the source module folder structure intact with what configuration expects.
- Watch the Network tab for 404/500/0-status responses when selecting modules.
- Treat a non-200 load as fatal and abort the build rather than alerting and continuing with empty text.
When it happens
Trigger: Opening builder.html directly via the file:// protocol (modern browsers block synchronous local XHR -> status 0); a selected module's source file is missing (404); the dev server returns 500 or a redirect; the base path/folder structure changed; mixed-content or CORS blocking on the request.
Common situations: Double-clicking builder.html to open it locally instead of serving it over HTTP; running the builder after renaming/removing a source module that is still checked; pointing at a folder layout that no longer matches configuration; a stale dev server returning errors for a path.
Related errors
- Font is not stored as string-data in vFS, import fonts or re
- Font does not exist in vFS, import fonts or remove declarati
AI-assisted analysis of parallax/jsPDF@a3930ce03a (2026-08-13).
Data as JSON: /api/errors/f9e83ea9dbbf16a2.
Report an issue: GitHub.